1 23 24 package com.rift.coad.lib.security.user; 26 27 import com.rift.coad.lib.configuration.Configuration; 29 import com.rift.coad.lib.configuration.ConfigurationFactory; 30 import com.rift.coad.lib.security.Validator; 31 import com.rift.coad.lib.security.AuthorizationException; 32 import com.rift.coad.lib.security.SecurityException; 33 34 35 40 public class UserStoreManagerAccessor { 41 42 private final static String ROLE = "role"; 44 45 private static UserStoreManagerAccessor singleton = null; 47 48 private UserStoreManager userStoreManager = null; 50 private String role = null; 51 52 58 private UserStoreManagerAccessor(UserStoreManager userStoreManager) 59 throws UserException { 60 try { 61 this.userStoreManager = userStoreManager; 62 Configuration configuration = 63 ConfigurationFactory.getInstance().getConfig(this.getClass()); 64 role = configuration.getString(ROLE); 65 } catch (Exception ex) { 66 throw new UserException ( 67 "Failed to instanciate the user store manager accessor : " + 68 ex.getMessage(),ex); 69 } 70 } 71 72 73 80 public synchronized static UserStoreManagerAccessor init( 81 UserStoreManager userStoreManager) 82 throws UserException { 83 if (singleton == null) { 84 singleton = new UserStoreManagerAccessor(userStoreManager); 85 } 86 return singleton; 87 } 88 89 90 96 public synchronized static UserStoreManagerAccessor getInstance() 97 throws UserException { 98 if (singleton == null) { 99 throw new UserException( 100 "The user store manager accessor has not been instanciated"); 101 } 102 return singleton; 103 } 104 105 106 113 public UserStoreManager getUserStoreManager() 114 throws AuthorizationException, SecurityException { 115 Validator.validate(this.getClass(),role); 116 return userStoreManager; 117 } 118 } 119 | Popular Tags |