Search in sources :

Example 1 with MethodPermissionMetaData

use of org.jboss.metadata.ejb.spec.MethodPermissionMetaData in project wildfly by wildfly.

the class MethodPermissionsMergingProcessor method handleMethodPermissions.

private void handleMethodPermissions(final EJBComponentDescription componentDescription, final MethodPermissionsMetaData methodPermissions) {
    for (final MethodPermissionMetaData methodPermissionMetaData : methodPermissions) {
        final MethodsMetaData methods = methodPermissionMetaData.getMethods();
        for (final MethodMetaData method : methods) {
            EJBMethodSecurityAttribute ejbMethodSecurityMetaData;
            // Enterprise Beans 3.1 FR 17.3.2.2 The unchecked element is used instead of a role name in the method-permission element to indicate that all roles are permitted.
            if (methodPermissionMetaData.isNotChecked()) {
                ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.permitAll();
            } else {
                ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.rolesAllowed(methodPermissionMetaData.getRoles());
            }
            final String methodName = method.getMethodName();
            final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
            final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
            if (methodName.equals("*")) {
                final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle1(methodIntf, null);
                ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, null, ejbMethodSecurityMetaData);
            } else {
                final MethodParametersMetaData methodParams = method.getMethodParams();
                // update the session bean description with the tx attribute info
                if (methodParams == null) {
                    final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle2(methodIntf, methodName);
                    ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                    componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, methodName);
                } else {
                    final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle3(methodIntf, null, methodName, this.getMethodParams(methodParams));
                    ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                    componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, null, methodName, this.getMethodParams(methodParams));
                }
            }
        }
    }
}
Also used : MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) EJBMethodSecurityAttribute(org.jboss.as.ejb3.security.EJBMethodSecurityAttribute) MethodsMetaData(org.jboss.metadata.ejb.spec.MethodsMetaData) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodPermissionMetaData(org.jboss.metadata.ejb.spec.MethodPermissionMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf)

Aggregations

MethodIntf (org.jboss.as.ejb3.component.MethodIntf)1 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)1 EJBMethodSecurityAttribute (org.jboss.as.ejb3.security.EJBMethodSecurityAttribute)1 MethodMetaData (org.jboss.metadata.ejb.spec.MethodMetaData)1 MethodParametersMetaData (org.jboss.metadata.ejb.spec.MethodParametersMetaData)1 MethodPermissionMetaData (org.jboss.metadata.ejb.spec.MethodPermissionMetaData)1 MethodsMetaData (org.jboss.metadata.ejb.spec.MethodsMetaData)1