package org.jboss.metadata;
import org.jboss.deployment.DeploymentException;
import org.w3c.dom.Element;
public class SecurityIdentityMetaData extends MetaData
{
private String description;
private boolean useCallerIdentity;
private String runAsRoleName;
private String runAsPrincipalName;
public String getDescription()
{
return description;
}
public boolean getUseCallerIdentity()
{
return useCallerIdentity;
}
public String getRunAsRoleName()
{
return runAsRoleName;
}
public String getRunAsPrincipalName()
{
return runAsPrincipalName;
}
public void setRunAsPrincipalName(String principalName)
{
this.runAsPrincipalName = principalName;
}
public void importEjbJarXml(Element element) throws DeploymentException
{
description = getElementContent(getOptionalChild(element, "description"));
Element callerIdent = getOptionalChild(element, "use-caller-identity");
Element runAs = getOptionalChild(element, "run-as");
if (callerIdent == null && runAs == null)
throw new DeploymentException("security-identity: either use-caller-identity or run-as must be specified");
if (callerIdent != null && runAs != null)
throw new DeploymentException("security-identity: only one of use-caller-identity or run-as can be specified");
if (callerIdent != null)
{
useCallerIdentity = true;
}
else
{
runAsRoleName = getElementContent(getUniqueChild(runAs, "role-name"));
}
}
}