}
}
private Security buildSecurityConfig(GerSecurityType securityType) {
Security security;
if (securityType == null) {
return null;
}
security = new Security();
security.setDoAsCurrentCaller(securityType.getDoasCurrentCaller());
security.setUseContextHandler(securityType.getUseContextHandler());
if (securityType.isSetDefaultRole()) {
security.setDefaultRole(securityType.getDefaultRole().trim());
}
if (securityType.isSetRoleMappings()) {
GerRoleMappingsType roleMappingsType = securityType.getRoleMappings();
for (int i = 0; i < roleMappingsType.sizeOfRoleArray(); i++) {
GerRoleType roleType = roleMappingsType.getRoleArray(i);
Role role = new Role();
String roleName = roleType.getRoleName().trim();
role.setRoleName(roleName);
if (roleType.isSetRunAsSubject()) {
SubjectInfo subjectInfo = buildSubjectInfo(roleType.getRunAsSubject());
security.getRoleSubjectMappings().put(roleName, subjectInfo);
}
for (int j = 0; j < roleType.sizeOfRealmPrincipalArray(); j++) {
role.getRealmPrincipals().add(GeronimoSecurityBuilderImpl.buildRealmPrincipal(roleType.getRealmPrincipalArray(j)));
}
for (int j = 0; j < roleType.sizeOfLoginDomainPrincipalArray(); j++) {
role.getLoginDomainPrincipals().add(GeronimoSecurityBuilderImpl.buildDomainPrincipal(roleType.getLoginDomainPrincipalArray(j)));
}
for (int j = 0; j < roleType.sizeOfPrincipalArray(); j++) {
role.getPrincipals().add(buildPrincipal(roleType.getPrincipalArray(j)));
}
security.getRoleMappings().put(roleName, role);
}
}
security.setDefaultSubjectInfo(buildSubjectInfo(securityType.getDefaultSubject()));
return security;
}