Search in sources :

Example 1 with SecurityPermission

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

the class ConnectorConfigurationParserServiceImpl method getSecurityPermissionSpec.

/**
 * Obtains the Permission string that needs to be added to the
 * to the security policy files. These are the security permissions needed
 * by the resource adapter implementation classes.
 * These strings are obtained by parsing the ra.xml
 *
 * @param moduleName rar module Name
 * @return Required policy permissions in server.policy file
 * @throws ConnectorRuntimeException If rar.xml parsing fails.
 */
public String getSecurityPermissionSpec(String moduleName) throws ConnectorRuntimeException {
    if (moduleName == null) {
        return null;
    }
    String policyString = null;
    // check whether the policy file already has required permissions.
    String fileName = System.getProperty("java.security.policy");
    if (fileName != null) {
        File policyFile = new File(fileName);
        String policyContent = getFileContent(policyFile);
        ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(moduleName);
        Set securityPermissions = connectorDescriptor.getSecurityPermissions();
        Iterator it = securityPermissions.iterator();
        SecurityPermission secPerm = null;
        String permissionString = null;
        while (it.hasNext()) {
            secPerm = (SecurityPermission) it.next();
            permissionString = secPerm.getPermission();
            int intIndex = policyContent.indexOf(permissionString);
            if (intIndex == -1) {
                if (permissionString != null) {
                    if (policyString != null) {
                        policyString = policyString + "\n \n" + permissionString;
                    } else {
                        policyString = "\n\n" + permissionString;
                    }
                }
            }
        }
        // print the missing permissions
        if (policyString != null) {
            policyString = CAUTION_MESSAGE + policyString;
        }
    }
    return policyString;
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) Set(java.util.Set) Iterator(java.util.Iterator) File(java.io.File) SecurityPermission(com.sun.enterprise.deployment.SecurityPermission)

Example 2 with SecurityPermission

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

the class SecurityPermissionNode method writeDescriptor.

/**
 * write the descriptor class to a DOM tree and return it
 *
 * @param parent node for the DOM tree
 * @param the descriptor to write
 * @return the DOM tree top node
 */
public Node writeDescriptor(Node parent, ConnectorDescriptor descriptor) {
    Iterator secPerms = descriptor.getSecurityPermissions().iterator();
    // auth mechanism info
    for (; secPerms.hasNext(); ) {
        // for (Iterator secPerms = ((OutboundResourceAdapter)descriptor).getSecurityPermissions().iterator(); secPerms.hasNext();) {
        SecurityPermission secPerm = (SecurityPermission) secPerms.next();
        Node secNode = appendChild(parent, ConnectorTagNames.SECURITY_PERMISSION);
        writeLocalizedDescriptions(secNode, secPerm);
        appendTextChild(secNode, ConnectorTagNames.SECURITY_PERMISSION_SPEC, secPerm.getPermission());
    }
    return null;
}
Also used : Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) Iterator(java.util.Iterator) SecurityPermission(com.sun.enterprise.deployment.SecurityPermission)

Aggregations

SecurityPermission (com.sun.enterprise.deployment.SecurityPermission)2 Iterator (java.util.Iterator)2 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 File (java.io.File)1 Set (java.util.Set)1 Node (org.w3c.dom.Node)1