1 19 20 package com.sslexplorer.properties.impl.userattributes; 21 22 import com.sslexplorer.core.UserDatabaseManager; 23 import com.sslexplorer.properties.attributes.AbstractAttributeKey; 24 import com.sslexplorer.security.User; 25 26 public class UserAttributeKey extends AbstractAttributeKey { 27 28 private User user; 29 30 public UserAttributeKey(String username, String name, int realm) throws IllegalArgumentException { 31 super(name, UserAttributes.NAME); 32 try { 33 user = UserDatabaseManager.getInstance().getUserDatabase(realm).getAccount(username); 34 } 35 catch(Exception e) { 36 throw new IllegalArgumentException ("Could not retrieve user for username '" + username + "'"); 37 } 38 } 39 40 public UserAttributeKey(User user, String name) { 41 super(name, UserAttributes.NAME); 42 this.user = user; 43 } 44 45 public User getUser() { 46 return user; 47 } 48 49 public String getAttributeClassKey() { 50 return getUser().getPrincipalName() + "_" + getUser().getRealm().getResourceId(); 51 } 52 53 } 54 | Popular Tags |