1 23 24 package com.rift.coad.lib.security.user.xml; 26 27 import java.util.Set ; 29 import java.util.HashSet ; 30 import com.rift.coad.lib.security.UserSession; 31 import com.rift.coad.lib.security.user.UserException; 32 33 38 public class UserData { 39 40 private String username = null; 42 private String password = null; 43 private Set principals = null; 44 45 46 53 public UserData(String username, String password) { 54 this.username = username; 55 this.password = password; 56 principals = new HashSet (); 57 } 58 59 60 66 public void setUsername(String username) { 67 this.username = username; 68 } 69 70 71 76 public String getUsername() { 77 return username; 78 } 79 80 81 86 public void setPassword(String password) { 87 this.password = password; 88 } 89 90 91 96 public String getPassword() { 97 return password; 98 } 99 100 101 106 public void addPrincipal(String principal) { 107 principals.add(principal); 108 } 109 110 111 117 public Set getPrincipals() { 118 return principals; 119 } 120 121 122 127 public boolean isInitialized() { 128 if ((username == null) || (password == null)) { 129 return false; 130 } 131 return true; 132 } 133 134 135 140 public UserSession getUser() throws UserException { 141 try { 142 return new UserSession(username,principals); 143 } catch (Exception ex) { 144 throw new UserException ( 145 "Failed to instanciate the user exception : " + 146 ex.getMessage(),ex); 147 } 148 } 149 } 150 | Popular Tags |