Search in sources :

Example 11 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class DeclareRolesHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    DeclareRoles rolesRefAn = (DeclareRoles) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDescriptor = ejbContext.getDescriptor();
        for (String roleName : rolesRefAn.value()) {
            if (ejbDescriptor.getRoleReferenceByName(roleName) == null) {
                RoleReference roleRef = new RoleReference(roleName, "");
                roleRef.setRoleName(roleName);
                roleRef.setSecurityRoleLink(new SecurityRoleDescriptor(roleName, ""));
                ejbDescriptor.addRoleReference(roleRef);
            }
            Role role = new Role(roleName);
            ejbDescriptor.getEjbBundleDescriptor().addRole(role);
        }
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) DeclareRoles(javax.annotation.security.DeclareRoles)

Example 12 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext 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 13 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class DeclareRolesHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    DeclareRoles rolesRefAn = (DeclareRoles) ainfo.getAnnotation();
    for (EjbContext ejbContext : ejbContexts) {
        EjbDescriptor ejbDescriptor = ejbContext.getDescriptor();
        for (String roleName : rolesRefAn.value()) {
            if (ejbDescriptor.getRoleReferenceByName(roleName) == null) {
                RoleReference roleRef = new RoleReference(roleName, "");
                roleRef.setRolename(roleName);
                roleRef.setSecurityRoleLink(new SecurityRoleDescriptor(roleName, ""));
                ejbDescriptor.addRoleReference(roleRef);
            }
            Role role = new Role(roleName);
            ejbDescriptor.getEjbBundleDescriptor().addRole(role);
        }
    }
    return getDefaultProcessedResult();
}
Also used : Role(org.glassfish.security.common.Role) EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) DeclareRoles(javax.annotation.security.DeclareRoles)

Example 14 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext 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 15 with EjbContext

use of com.sun.enterprise.deployment.annotation.context.EjbContext in project Payara by payara.

the class AroundInvokeHandler method processAnnotation.

protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
    for (EjbContext next : ejbContexts) {
        EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
        ejbDescriptor.addAroundInvokeDescriptor(getAroundInvocationDescriptor(ainfo));
    }
    return getDefaultProcessedResult();
}
Also used : EjbContext(com.sun.enterprise.deployment.annotation.context.EjbContext) EjbDescriptor(org.glassfish.ejb.deployment.descriptor.EjbDescriptor)

Aggregations

EjbContext (com.sun.enterprise.deployment.annotation.context.EjbContext)26 Method (java.lang.reflect.Method)12 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)10 EjbDescriptor (org.glassfish.ejb.deployment.descriptor.EjbDescriptor)10 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)10 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)4 EjbsContext (com.sun.enterprise.deployment.annotation.context.EjbsContext)4 EjbBundleDescriptorImpl (org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)4 Role (org.glassfish.security.common.Role)4 AnnotatedElement (java.lang.reflect.AnnotatedElement)3 Constructor (java.lang.reflect.Constructor)3 AnnotationProcessorException (org.glassfish.apf.AnnotationProcessorException)3 InterceptorBindingDescriptor (org.glassfish.ejb.deployment.descriptor.InterceptorBindingDescriptor)3 RunAsIdentityDescriptor (com.sun.enterprise.deployment.RunAsIdentityDescriptor)2 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)2 WebBundleContext (com.sun.enterprise.deployment.annotation.context.WebBundleContext)2 WebComponentContext (com.sun.enterprise.deployment.annotation.context.WebComponentContext)2 Annotation (java.lang.annotation.Annotation)2 DeclareRoles (javax.annotation.security.DeclareRoles)2 RunAs (javax.annotation.security.RunAs)2