String domainName = (String) metaValueFactory.unwrap(compositeValue.get(DOMAIN));
SecurityDeploymentType deploymentType = (SecurityDeploymentType) metaValueFactory.unwrap(compositeValue.get(DeploymentTypeName));
if(deploymentType == null)
deploymentType = SecurityDeploymentType.NONE;
SecurityMetaData securityDomain = null;
switch(deploymentType)
{
case APPLICATION:
securityDomain = new ApplicationManagedSecurityMetaData();
break;
case DOMAIN:
securityDomain = new SecurityDomainMetaData();
break;
case DOMAIN_AND_APPLICATION:
securityDomain = new SecurityDomainApplicationManagedMetaData();
break;
default:
case NONE:
securityDomain = new SecurityMetaData();
break;
}
// Sanity check
if(securityDomain.requiresDomain() && domainName == null)
throw new IllegalStateException("null security domain not allowed for SecurityDeploymentType " + deploymentType);
// Set the domain
securityDomain.setDomain(domainName);
//
return securityDomain;
}
throw new IllegalStateException("Unable to unwrap securityDomain " + metaValue);
}