if (security != null) {
RoleMappingsType roleMappings = security.getRoleMappings();
if (roleMappings != null) {
RoleType[] roles = roleMappings.getRoleArray();
for (int i = 0; i < roles.length; i++) {
RoleType role = roles[i];
RealmType[] realms = role.getRealmArray();
for (int j = 0; j < realms.length; j++) {
RealmType realm = realms[j];
PrincipalType[] principals = realm.getPrincipalArray();
HashSet set = new HashSet();
for (int k = 0; k < principals.length; k++) {
PrincipalType principal = principals[k];
java.security.Principal p = null;
try {
Class clazz = Class.forName(principal.getClass1());
Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class});
p = (java.security.Principal) constructor.newInstance(new Object[]{principal.getName()});
set.add(new RealmPrincipal(realm.getRealmName(), p));
} catch (InstantiationException e) {
throw new GeronimoSecurityException(e);
} catch (IllegalAccessException e) {
throw new GeronimoSecurityException(e);
} catch (ClassNotFoundException e) {
throw new GeronimoSecurityException(e);
} catch (NoSuchMethodException e) {
throw new GeronimoSecurityException(e);
} catch (InvocationTargetException e) {
throw new GeronimoSecurityException(e);
}
}
super.addRoleMapping(role.getRoleName(), set);
}
}
}
}
}