Search in sources :

Example 6 with MethodPermission

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

the class EjbDescriptor method print.

/**
 * Returns a formatted String of the attributes of this object.
 * @param toStringBuffer
 */
@Override
public void print(StringBuffer toStringBuffer) {
    super.print(toStringBuffer);
    toStringBuffer.append("\n homeClassName ").append(homeClassName);
    toStringBuffer.append("\n remoteClassName ").append(remoteClassName);
    toStringBuffer.append("\n remoteBusinessIntfs ").append(remoteBusinessClassNames).append("\n");
    toStringBuffer.append("\n localhomeClassName ").append(localHomeClassName);
    toStringBuffer.append("\n localClassName ").append(localClassName);
    toStringBuffer.append("\n localBusinessIntfs ").append(localBusinessClassNames);
    toStringBuffer.append("\n isLocalBean ").append(isLocalBean()).append("\n");
    toStringBuffer.append("\n jndiName ").append(jndiName).append("\n");
    toStringBuffer.append("\n ejbClassName ").append(ejbClassName);
    toStringBuffer.append("\n transactionType ").append(transactionType);
    toStringBuffer.append("\n methodContainerTransactions ").append(getMethodContainerTransactions());
    toStringBuffer.append("\n environmentProperties ");
    if (environmentProperties != null)
        printDescriptorSet(environmentProperties, toStringBuffer);
    toStringBuffer.append("\n ejbReferences ");
    if (ejbReferences != null)
        printDescriptorSet(ejbReferences, toStringBuffer);
    toStringBuffer.append("\n resourceEnvReferences ");
    if (resourceEnvReferences != null)
        printDescriptorSet(resourceEnvReferences, toStringBuffer);
    toStringBuffer.append("\n messageDestReferences ");
    if (messageDestReferences != null)
        printDescriptorSet(messageDestReferences, toStringBuffer);
    toStringBuffer.append("\n resourceReferences ");
    if (resourceReferences != null)
        printDescriptorSet(resourceReferences, toStringBuffer);
    toStringBuffer.append("\n serviceReferences ");
    if (serviceReferences != null)
        printDescriptorSet(serviceReferences, toStringBuffer);
    toStringBuffer.append("\n roleReferences ");
    if (roleReferences != null)
        printDescriptorSet(roleReferences, toStringBuffer);
    for (Iterator e = this.getPermissionedMethodsByPermission().keySet().iterator(); e.hasNext(); ) {
        MethodPermission nextPermission = (MethodPermission) e.next();
        toStringBuffer.append("\n method-permission->method: ");
        nextPermission.print(toStringBuffer);
        toStringBuffer.append(" -> ").append(this.getPermissionedMethodsByPermission().get(nextPermission));
    }
}
Also used : Iterator(java.util.Iterator) MethodPermission(com.sun.enterprise.deployment.MethodPermission)

Example 7 with MethodPermission

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

the class EjbDescriptor method updateMethodPermissionForMethod.

/**
 * Update a method descriptor set of method permission with a new method permission
 * The new method permission is added to the list of existing method permissions
 * given it respect the EJB 2.0 paragraph 21.3.2 on priorities of method permissions
 *
 * @param mp is the method permission to be added
 * @param md is the method descriptor (style3 only) to add the method permission to
 */
private void updateMethodPermissionForMethod(MethodPermission mp, MethodDescriptor md) {
    // Get the current set of method permissions for that method
    Set oldPermissions = getMethodPermissions(md);
    if (oldPermissions.isEmpty()) {
        // this is easy, just add the new one
        addMethodPermissionForMethod(mp, md);
        return;
    }
    if (mp.isExcluded()) {
        // remove all existing method permission...
        for (Iterator oldPermissionsItr = oldPermissions.iterator(); oldPermissionsItr.hasNext(); ) {
            MethodPermission oldMp = (MethodPermission) oldPermissionsItr.next();
            removePermissionedMethod(oldMp, md);
        }
        // add the excluded
        addMethodPermissionForMethod(mp, md);
    } else {
        if (mp.isUnchecked()) {
            // particular method has an excluded method permision, we do not add it
            for (Iterator oldPermissionsItr = oldPermissions.iterator(); oldPermissionsItr.hasNext(); ) {
                MethodPermission oldMp = (MethodPermission) oldPermissionsItr.next();
                if (!oldMp.isExcluded()) {
                    removePermissionedMethod(oldMp, md);
                    addMethodPermissionForMethod(mp, md);
                }
            }
        } else {
            // and add it to the current list of role based permission
            for (Iterator oldPermissionsItr = oldPermissions.iterator(); oldPermissionsItr.hasNext(); ) {
                MethodPermission oldMp = (MethodPermission) oldPermissionsItr.next();
                if (!oldMp.isExcluded()) {
                    if (!oldMp.isUnchecked()) {
                        addMethodPermissionForMethod(mp, md);
                    }
                }
            }
        }
    }
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) Iterator(java.util.Iterator) MethodPermission(com.sun.enterprise.deployment.MethodPermission)

Example 8 with MethodPermission

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

the class EjbDescriptor method removeRole.

void removeRole(Role role) {
    // this.getPermissionedRoles().remove(role);
    this.getPermissionedMethodsByPermission().remove(new MethodPermission(role));
    Set roleReferences = new HashSet(this.getRoleReferences());
    for (Iterator itr = roleReferences.iterator(); itr.hasNext(); ) {
        RoleReference roleReference = (RoleReference) itr.next();
        if (roleReference.getRole().equals(role)) {
            roleReference.setValue("");
        }
    }
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) RoleReference(com.sun.enterprise.deployment.RoleReference) Iterator(java.util.Iterator) MethodPermission(com.sun.enterprise.deployment.MethodPermission) HashSet(java.util.HashSet)

Example 9 with MethodPermission

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

the class EjbDescriptor method getMethodPermissions.

private Set getMethodPermissions(MethodDescriptor methodDescriptor) {
    Set methodPermissionsForMethod = new HashSet();
    for (Iterator e = this.getPermissionedMethodsByPermission().keySet().iterator(); e.hasNext(); ) {
        MethodPermission nextPermission = (MethodPermission) e.next();
        Set permissionedMethods = (Set) this.getPermissionedMethodsByPermission().get(nextPermission);
        for (Iterator itr = permissionedMethods.iterator(); itr.hasNext(); ) {
            MethodDescriptor md = (MethodDescriptor) itr.next();
            if (md.equals(methodDescriptor)) {
                methodPermissionsForMethod.add(nextPermission);
            }
        }
    }
    return methodPermissionsForMethod;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) Iterator(java.util.Iterator) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) MethodPermission(com.sun.enterprise.deployment.MethodPermission) HashSet(java.util.HashSet)

Example 10 with MethodPermission

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

the class EjbDescriptor method getAllMethodDescriptors.

Set getAllMethodDescriptors() {
    Set allMethodDescriptors = new HashSet();
    for (Enumeration e = getMethodContainerTransactions().keys(); e.hasMoreElements(); ) {
        allMethodDescriptors.add(e.nextElement());
    }
    for (Iterator e = this.getPermissionedMethodsByPermission().keySet().iterator(); e.hasNext(); ) {
        MethodPermission nextPermission = (MethodPermission) e.next();
        Set permissionedMethods = (Set) this.getPermissionedMethodsByPermission().get(nextPermission);
        for (Iterator itr = permissionedMethods.iterator(); itr.hasNext(); ) {
            allMethodDescriptors.add(itr.next());
        }
    }
    return allMethodDescriptors;
}
Also used : Set(java.util.Set) OrderedSet(com.sun.enterprise.deployment.OrderedSet) HashSet(java.util.HashSet) Enumeration(java.util.Enumeration) Iterator(java.util.Iterator) MethodPermission(com.sun.enterprise.deployment.MethodPermission) HashSet(java.util.HashSet)

Aggregations

MethodPermission (com.sun.enterprise.deployment.MethodPermission)19 Iterator (java.util.Iterator)11 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)10 Set (java.util.Set)8 HashSet (java.util.HashSet)7 OrderedSet (com.sun.enterprise.deployment.OrderedSet)6 Map (java.util.Map)4 Role (org.glassfish.security.common.Role)4 MethodPermissionDescriptor (com.sun.enterprise.deployment.MethodPermissionDescriptor)2 RoleReference (com.sun.enterprise.deployment.RoleReference)2 Result (com.sun.enterprise.tools.verifier.Result)2 ComponentNameConstructor (com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor)2 Enumeration (java.util.Enumeration)2 HashMap (java.util.HashMap)2 RolesAllowed (javax.annotation.security.RolesAllowed)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)1 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)1 EjbIORConfigurationDescriptor (com.sun.enterprise.deployment.EjbIORConfigurationDescriptor)1 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)1 ResourceEnvReferenceDescriptor (com.sun.enterprise.deployment.ResourceEnvReferenceDescriptor)1