1 7 package winstone; 8 9 import java.io.Serializable ; 10 import java.security.Principal ; 11 import java.util.List ; 12 13 20 public class AuthenticationPrincipal implements Principal , Serializable { 21 private String userName; 22 private String password; 23 private List roles; 24 private String authenticationType; 25 26 29 public AuthenticationPrincipal(String userName, String password, List roles) { 30 this.userName = userName; 31 this.password = password; 32 this.roles = roles; 33 } 34 35 public String getName() { 36 return this.userName; 37 } 38 39 public String getPassword() { 40 return this.password; 41 } 42 43 public String getAuthType() { 44 return this.authenticationType; 45 } 46 47 public void setAuthType(String authType) { 48 this.authenticationType = authType; 49 } 50 51 54 public boolean isUserIsInRole(String role) { 55 if (this.roles == null) 56 return false; 57 else if (role == null) 58 return false; 59 else 60 return this.roles.contains(role); 61 } 62 } 63 | Popular Tags |