Search in sources :

Example 6 with RunAsIdentityDescriptor

use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.

the class RunAsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    RunAs runAsAn = (RunAs) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        // override by xml
        if (ejbDesc.getUsesCallerIdentity() != null) {
            continue;
        }
        String roleName = runAsAn.value();
        Role role = new Role(roleName);
        // add Role if not exists
        ejbDesc.getEjbBundleDescriptor().addRole(role);
        RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
        runAsDesc.setRoleName(roleName);
        ejbDesc.setUsesCallerIdentity(false);
        if (ejbDesc.getRunAsIdentity() == null) {
            ejbDesc.setRunAsIdentity(runAsDesc);
        }
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) RunAs(javax.annotation.security.RunAs) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 7 with RunAsIdentityDescriptor

use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.

the class RunAsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, WebComponentContext[] webCompContexts) throws AnnotationProcessorException {
    RunAs runAsAn = (RunAs) ainfo.getAnnotation();
    for (WebComponentContext webCompContext : webCompContexts) {
        WebComponentDescriptor webDesc = webCompContext.getDescriptor();
        // override by xml
        if (webDesc.getRunAsIdentity() != null) {
            continue;
        }
        String roleName = runAsAn.value();
        Role role = new Role(roleName);
        // add Role if not exists
        webDesc.getWebBundleDescriptor().addRole(role);
        RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
        runAsDesc.setRoleName(roleName);
        webDesc.setRunAsIdentity(runAsDesc);
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) WebComponentContext(com.sun.enterprise.deployment.annotation.context.WebComponentContext) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) RunAs(javax.annotation.security.RunAs)

Example 8 with RunAsIdentityDescriptor

use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.

the class RunAsHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    RunAs runAsAn = (RunAs) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDesc = ejbContext.getDescriptor();
        // override by xml
        if (ejbDesc.getUsesCallerIdentity() != null) {
            continue;
        }
        String roleName = runAsAn.value();
        Role role = new Role(roleName);
        // add Role if not exists
        ejbDesc.getEjbBundleDescriptor().addRole(role);
        RunAsIdentityDescriptor runAsDesc = new RunAsIdentityDescriptor();
        runAsDesc.setRoleName(roleName);
        ejbDesc.setUsesCallerIdentity(false);
        if (ejbDesc.getRunAsIdentity() == null) {
            ejbDesc.setRunAsIdentity(runAsDesc);
        }
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) RunAs(javax.annotation.security.RunAs) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 9 with RunAsIdentityDescriptor

use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.

the class RealmAdapter method initializeRealm.

@Override
public void initializeRealm(Object descriptor, boolean isSystemApp, String realmName) {
    this.isSystemApp = isSystemApp;
    webDescriptor = (WebBundleDescriptor) descriptor;
    computeRealmName(webDescriptor, realmName);
    CONTEXT_ID = WebSecurityManager.getContextID(webDescriptor);
    runAsPrincipals = new HashMap<String, String>();
    for (WebComponentDescriptor componentDescriptor : webDescriptor.getWebComponentDescriptors()) {
        RunAsIdentityDescriptor runAsDescriptor = componentDescriptor.getRunAsIdentity();
        if (runAsDescriptor != null) {
            String principal = runAsDescriptor.getPrincipal();
            String servlet = componentDescriptor.getCanonicalName();
            if (principal == null || servlet == null) {
                logger.warning("web.realmadapter.norunas");
            } else {
                runAsPrincipals.put(servlet, principal);
                logger.fine("Servlet " + servlet + " will run-as: " + principal);
            }
        }
    }
    this.moduleID = webDescriptor.getModuleID();
}
Also used : WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor)

Example 10 with RunAsIdentityDescriptor

use of com.sun.enterprise.deployment.RunAsIdentityDescriptor in project Payara by payara.

the class ASEjbPrincipal method check.

public Result check(EjbDescriptor descriptor) {
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    boolean oneFailed = false;
    try {
        if (descriptor.getUsesCallerIdentity() == false) {
            RunAsIdentityDescriptor runAsIdDesc = descriptor.getRunAsIdentity();
            if (runAsIdDesc != null) {
                String principal = runAsIdDesc.getPrincipal();
                if (principal == null) {
                    addNaDetails(result, compName);
                    result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] : principal element not defined"));
                } else {
                    if (principal.length() == 0) {
                        addErrorDetails(result, compName);
                        result.failed(smh.getLocalString(getClass().getName() + ".failed", "FAILED [AS-EJB principal] : name cannot be an empty String"));
                    } else {
                        addGoodDetails(result, compName);
                        result.passed(smh.getLocalString(getClass().getName() + ".passed", "PASSED [AS-EJB principal] : name is {0}", new Object[] { principal }));
                    }
                }
            }
        } else {
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString(getClass().getName() + ".notApplicable", "NOT APPLICABLE [AS-EJB ejb] run-as Element is not defined"));
        }
    } catch (Exception ex) {
        addErrorDetails(result, compName);
        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".notRun", "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
    }
    return result;
}
Also used : RunAsIdentityDescriptor(com.sun.enterprise.deployment.RunAsIdentityDescriptor) ComponentNameConstructor(com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor) Result(com.sun.enterprise.tools.verifier.Result)

Aggregations

RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)12 Role (org.glassfish.security.common.Role)7 RunAs (javax.annotation.security.RunAs)5 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)4 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)3 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)2 EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)2 WebComponentContext (com.sun.enterprise.deployment.annotation.context.WebComponentContext)2 Result (com.sun.enterprise.tools.verifier.Result)2 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)2 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbSessionDescriptor (com.sun.enterprise.deployment.EjbSessionDescriptor)1 MessageDestinationReferenceDescriptor (com.sun.enterprise.deployment.MessageDestinationReferenceDescriptor)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 MethodPermission (com.sun.enterprise.deployment.MethodPermission)1 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 XMLElement (com.sun.enterprise.deployment.node.XMLElement)1 EjbRefNode (com.sun.enterprise.deployment.node.runtime.EjbRefNode)1