1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
| package com.hopeless.security;
import java.util.ArrayList;
import java.util.Collection;
import org.springframework.security.core.GrantedAuthority;
import com.hopeless.utils.ConstantesConfig;
// TODO: Auto-generated Javadoc
/**
* The Class UserDetailSecurityImpl.
*/
public class UserDetailSecurityImpl implements org.springframework.security.core.userdetails.UserDetails {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -5024829739284004929L;
/** The _username. */
private String username;
/** The _password. */
private String password;
/** The _autorites. */
private Collection<GrantedAuthority> listAutorites;
/** The id joueur. */
private Long idJoueur;
/** The enabled. */
private boolean enabled;
/**
* Constructeur ayant en parametre le nom de l'utilisateur.
*
* @param user the username
*/
public UserDetailSecurityImpl(String user) {
username = user;
listAutorites = new ArrayList<GrantedAuthority>();
addAuthorities(ConstantesConfig.ROLE_LOGGED);
addAuthorities(ConstantesConfig.ROLE_ANONYMOUS);
}
/**
* Methode permetant de mettre le password.
*
* @param newPassword the new password
*/
public void setPassword(String newPassword) {
password = newPassword;
}
/**
* Methode permetant de mettre les autorites.
*
* @param autorities the autorities
*/
public void addAuthorities(String autorities) {
listAutorites.add(new GrantedAutorityImpl(autorities));
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#getAuthorities()
*/
@Override
public Collection<GrantedAuthority> getAuthorities() {
return listAutorites;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#getPassword()
*/
@Override
public String getPassword() {
return password;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#getUsername()
*/
@Override
public String getUsername() {
return username;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#isAccountNonExpired()
*/
@Override
public boolean isAccountNonExpired() {
return true;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#isAccountNonLocked()
*/
@Override
public boolean isAccountNonLocked() {
return true;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#isCredentialsNonExpired()
*/
@Override
public boolean isCredentialsNonExpired() {
return true;
}
/* (non-Javadoc)
* @see org.springframework.security.core.userdetails.UserDetails#isEnabled()
*/
@Override
public boolean isEnabled() {
return enabled;
}
/**
* Sets the enabled.
*
* @param newEnabled the new enabled
*/
public void setEnabled(boolean newEnabled) {
enabled = newEnabled;
}
/**
* Gets the id joueur.
*
* @return the idJoueur
*/
public Long getIdJoueur() {
return idJoueur;
}
/**
* Sets the id joueur.
*
* @param newIdJoueur the idJoueur to set
*/
public void setIdJoueur(Long newIdJoueur) {
this.idJoueur = newIdJoueur;
}
} |
Partager