public DirectConfigurationCredentialStoreImpl(Map<String, String> subjectInfo,
ClassLoader cl) throws DeploymentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (cl == null) {
cl = getClass().getClassLoader();
}
for (Map.Entry< String, Map< String, Map< String, String > > > realmEntry: subjectInfo.entrySet()) {
Map< String, Subject > realm = new HashMap< String, Subject >();
for (Map.Entry< String, Map< String, String > > subjectEntry: realmEntry.getValue().entrySet()) {
String id = subjectEntry.getKey();
Map< String, String > principals = subjectEntry.getValue();
Subject subject = new Subject();
for (Map.Entry< String, String > principalInfo: principals.entrySet()) {
String className = principalInfo.getKey();
String principalName = principalInfo.getValue();
Class< ? extends Principal > clazz = (Class< ? extends Principal >) cl.loadClass(className);
Constructor< ? extends Principal > c = clazz.getConstructor(new Class[] {String.class});
Principal p = c.newInstance(new Object[] {principalName});
subject.getPrincipals().add(p);
}
realm.put(id, subject);
}
subjectStore.put(realmEntry.getKey(), realm);
}
}
|