Rev 216 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 216 | Rev 218 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | 4 | ||
| 5 | //import org.apache.commons.lang.builder.EqualsBuilder;
|
- | |
| 6 | //import org.apache.commons.lang.builder.HashCodeBuilder;
|
- | |
| - | 5 | import org.apache.commons.lang.builder.EqualsBuilder; |
|
| - | 6 | import org.apache.commons.lang.builder.HashCodeBuilder; |
|
| 7 | import org.springframework.security.core.Authentication; |
7 | import org.springframework.security.core.Authentication; |
| 8 | import org.springframework.security.core.GrantedAuthority; |
8 | import org.springframework.security.core.GrantedAuthority; |
| 9 | 9 | ||
| - | 10 | import br.com.ec.domain.dto.UsuarioDTO; |
|
| 10 | import br.com.ec.domain.modal.Usuario; |
11 | import br.com.ec.domain.modal.Usuario; |
| 11 | 12 | ||
| 12 | public class SistemaAuthentication implements Authentication { |
13 | public class SistemaAuthentication implements Authentication { |
| 13 | 14 | ||
| 14 | private static final long serialVersionUID = 1L; |
15 | private static final long serialVersionUID = 1L; |
| 15 | 16 | ||
| 16 | private String login; |
17 | private String login; |
| 17 | private String credencials; |
18 | private String credencials; |
| 18 | private Usuario usuario; |
- | |
| - | 19 | // private Usuario usuario;
|
|
| - | 20 | private UsuarioDTO usuario; |
|
| 19 | private Collection<GrantedAuthority> authorities; |
21 | private Collection<GrantedAuthority> authorities; |
| 20 | private boolean isAuthenticated; |
22 | private boolean isAuthenticated; |
| 21 | 23 | ||
| 22 | /**
|
24 | /**
|
| 23 | * Cria um Authentication autenticado (authenticated = true).
|
25 | * Cria um Authentication autenticado (authenticated = true).
|
| Line 25... | Line 27... | ||
| 25 | * @param login
|
27 | * @param login
|
| 26 | * @param credentiais
|
28 | * @param credentiais
|
| 27 | * @param usuario
|
29 | * @param usuario
|
| 28 | * @param authorities
|
30 | * @param authorities
|
| 29 | */
|
31 | */
|
| 30 | public SistemaAuthentication(String login, String credencials, Usuario usuario, Collection<GrantedAuthority> authorities) { |
- | |
| - | 32 | public SistemaAuthentication(String login, String credencials, UsuarioDTO usuario, Collection<GrantedAuthority> authorities) { |
|
| 31 | this.login = login; |
33 | this.login = login; |
| 32 | this.credencials = credencials; |
34 | this.credencials = credencials; |
| 33 | this.usuario = usuario; |
35 | this.usuario = usuario; |
| 34 | this.authorities = authorities; |
36 | this.authorities = authorities; |
| 35 | setAuthenticated(true); |
37 | setAuthenticated(true); |
| Line 52... | Line 54... | ||
| 52 | }
|
54 | }
|
| 53 | 55 | ||
| 54 | /**
|
56 | /**
|
| 55 | * @return usuario obtido no processo de autenticao ou nulo se nao autenticado.
|
57 | * @return usuario obtido no processo de autenticao ou nulo se nao autenticado.
|
| 56 | */
|
58 | */
|
| 57 | public Usuario getDetails() { |
- | |
| - | 59 | public UsuarioDTO getDetails() { |
|
| 58 | return usuario; |
60 | return usuario; |
| 59 | }
|
61 | }
|
| 60 | 62 | ||
| 61 | public Collection<GrantedAuthority> getAuthorities() { |
63 | public Collection<GrantedAuthority> getAuthorities() { |
| 62 | return authorities; |
64 | return authorities; |
| Line 70... | Line 72... | ||
| 70 | this.isAuthenticated = isAuthenticated; |
72 | this.isAuthenticated = isAuthenticated; |
| 71 | }
|
73 | }
|
| 72 | 74 | ||
| 73 | @Override |
75 | @Override |
| 74 | public boolean equals(Object objeto) { |
76 | public boolean equals(Object objeto) { |
| 75 | // return EqualsBuilder.reflectionEquals(this, objeto);
|
- | |
| 76 | return false; |
- | |
| - | 77 | return EqualsBuilder.reflectionEquals(this, objeto); |
|
| 77 | }
|
78 | }
|
| 78 | 79 | ||
| 79 | @Override |
80 | @Override |
| 80 | public int hashCode() { |
81 | public int hashCode() { |
| 81 | // return HashCodeBuilder.reflectionHashCode(this);-
|
- | |
| 82 | return 1; |
- | |
| - | 82 | return HashCodeBuilder.reflectionHashCode(this); |
|
| 83 | }
|
83 | }
|
| 84 | 84 | ||
| 85 | }
|
85 | }
|