XmlObject[] refs = container.selectChildren(SECURITY_REF_QNAME);
if (refs.length > 1) {
throw new DeploymentException("Unexpected count of security-ref elements in geronimo plan " + refs.length + " qname: " + SECURITY_REF_QNAME);
}
if (refs.length == 1) {
GerSecurityRefType ref;
try {
ref = (GerSecurityRefType) XmlBeansUtil.typedCopy(refs[0], GerSecurityRefType.type);
if (ref.isSetName()) {
String name = ref.getName().trim();
AbstractNameQuery roleMapperDataName = new AbstractNameQuery(null, Collections.singletonMap("name", name), PrincipalRoleMapper.class.getName());
setRoleMapperName(applicationContext, roleMapperDataName);
} else {
PatternType SecurityRefType = ref.getRef();
AbstractNameQuery roleMapperDataName = SingleGBeanBuilder.buildAbstractNameQuery(SecurityRefType, GBeanInfoBuilder.DEFAULT_J2EE_TYPE, Collections.singleton(CredentialStore.class.getName()));
setRoleMapperName(applicationContext, roleMapperDataName);
}
} catch (XmlException e) {
throw new DeploymentException("Could not validate security element", e);