Search in sources :

Example 6 with AuthMechanism

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

the class CredentialInterface method check.

/**
 * <p>
 * All Credential interface declared in the DD should be one of the
 * allowed interface
 * </p>
 *
 * @paramm descriptor deployment descriptor for the rar file
 * @return result object containing the result of the individual test
 * performed
 */
public Result check(ConnectorDescriptor descriptor) {
    boolean oneFailed = false;
    Result result = getInitializedResult();
    ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    if (!descriptor.getOutBoundDefined()) {
        result.addNaDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.notApplicable(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA", "Resource Adapter does not provide outbound communication"));
        return result;
    }
    Set mechanisms = descriptor.getOutboundResourceAdapter().getAuthMechanisms();
    if (mechanisms.isEmpty()) {
        // passed
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.nonexist", "No authentication mechanism defined for this resource adapater"));
        return result;
    }
    Iterator mechIterator = mechanisms.iterator();
    while (mechIterator.hasNext()) {
        AuthMechanism am = (AuthMechanism) mechIterator.next();
        String credInterface = am.getCredentialInterface();
        boolean allowedInterface = false;
        if (credInterface != null) {
            for (int i = 0; i < allowedInterfaces.length; i++) {
                if (credInterface.equals(allowedInterfaces[i])) {
                    allowedInterface = true;
                    break;
                }
            }
        }
        if (!allowedInterface || credInterface == null) {
            // failed
            oneFailed = true;
            result.addErrorDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
            result.failed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.failed", "Authentication mechanism credential interface [ {0} ] defined in the credential-interface tag is not allowed", new Object[] { credInterface }));
        }
    }
    if (!oneFailed) {
        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object[] { compName.toString() }));
        result.passed(smh.getLocalString("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.passed", "All defined authorization mechanism credential interfaces are allowed"));
    }
    return result;
}
Also used : AuthMechanism(com.sun.enterprise.deployment.AuthMechanism) Result(com.sun.enterprise.tools.verifier.Result)

Example 7 with AuthMechanism

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

the class AuthMechNode 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, Descriptor descriptor) {
    if (!(descriptor instanceof OutboundResourceAdapter) && !(descriptor instanceof ConnectorDescriptor)) {
        throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
    }
    Iterator authMechs = null;
    if (descriptor instanceof ConnectorDescriptor) {
        authMechs = ((ConnectorDescriptor) descriptor).getAuthMechanisms().iterator();
    } else if (descriptor instanceof OutboundResourceAdapter) {
        authMechs = ((OutboundResourceAdapter) descriptor).getAuthMechanisms().iterator();
    }
    // auth mechanism info
    if (authMechs != null) {
        for (; authMechs.hasNext(); ) {
            AuthMechanism auth = (AuthMechanism) authMechs.next();
            Node authNode = appendChild(parent, ConnectorTagNames.AUTH_MECHANISM);
            appendTextChild(authNode, TagNames.DESCRIPTION, auth.getDescription());
            appendTextChild(authNode, ConnectorTagNames.AUTH_MECH_TYPE, auth.getAuthMechType());
            appendTextChild(authNode, ConnectorTagNames.CREDENTIAL_INTF, auth.getCredentialInterface());
        }
    }
    return parent;
}
Also used : ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AuthMechanism(com.sun.enterprise.deployment.AuthMechanism) Node(org.w3c.dom.Node) DeploymentDescriptorNode(com.sun.enterprise.deployment.node.DeploymentDescriptorNode) Iterator(java.util.Iterator) OutboundResourceAdapter(com.sun.enterprise.deployment.OutboundResourceAdapter)

Aggregations

AuthMechanism (com.sun.enterprise.deployment.AuthMechanism)7 OutboundResourceAdapter (com.sun.enterprise.deployment.OutboundResourceAdapter)5 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)4 AuthenticationMechanism (javax.resource.spi.AuthenticationMechanism)3 RarBundleContext (com.sun.enterprise.deployment.annotation.context.RarBundleContext)2 Result (com.sun.enterprise.tools.verifier.Result)2 Set (java.util.Set)2 BasicPasswordAuthenticationService (com.sun.enterprise.connectors.authentication.BasicPasswordAuthenticationService)1 LicenseDescriptor (com.sun.enterprise.deployment.LicenseDescriptor)1 DeploymentDescriptorNode (com.sun.enterprise.deployment.node.DeploymentDescriptorNode)1 Iterator (java.util.Iterator)1 SecurityPermission (javax.resource.spi.SecurityPermission)1 WorkContext (javax.resource.spi.work.WorkContext)1 Node (org.w3c.dom.Node)1