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;
}
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;
}
Aggregations