|                                                                                                              1
 23
 28
 29  package com.sun.enterprise.tools.verifier.tests.connector;
 30
 31  import java.util.*;
 32  import com.sun.enterprise.tools.verifier.Result;
 33  import com.sun.enterprise.deployment.ConnectorDescriptor;
 34  import com.sun.enterprise.tools.verifier.tests.*;
 35  import com.sun.enterprise.deployment.AuthMechanism;
 36
 37
 44  public class CredentialInterface extends ConnectorTest implements ConnectorCheck {
 45
 46
 47      private static String
  [] allowedInterfaces = new String  [] { 48                                "javax.resource.spi.security.PasswordCredential",
 49                                "org.ietf.jgss.GSSCredential",
 50                                "javax.resource.spi.security.GenericCredential" };
 51
 52
 61      public Result check(ConnectorDescriptor descriptor) {
 62          boolean oneFailed = false;
 63          Result result = getInitializedResult();
 64      ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
 65          if(!descriptor.getOutBoundDefined())
 66          {
 67            result.addNaDetails(smh.getLocalString
 68                ("tests.componentNameConstructor",
 69                 "For [ {0} ]",
 70                 new Object
  [] {compName.toString()})); 71            result.notApplicable(smh.getLocalString
 72                ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA",
 73                 "Resource Adapter does not provide outbound communication"));
 74            return result;
 75          }
 76          Set mechanisms =
 77          descriptor.getOutboundResourceAdapter().getAuthMechanisms();
 78          if (mechanisms.isEmpty()) {
 79                      result.addGoodDetails(smh.getLocalString
 81                    ("tests.componentNameConstructor",
 82                     "For [ {0} ]",
 83                     new Object
  [] {compName.toString()})); 84          result.passed(smh.getLocalString
 85                  ("com.sun.enterprise.tools.verifier.tests.connector.AuthMechType.nonexist",
 86                   "No authentication mechanism defined for this resource adapater"));
 87              return result;
 88          }
 89          Iterator mechIterator = mechanisms.iterator();
 90          while (mechIterator.hasNext()) {
 91              AuthMechanism am = (AuthMechanism) mechIterator.next();
 92              String
  credInterface = am.getCredentialInterface(); 93              boolean allowedInterface = false;
 94              if (credInterface!=null) {
 95                  for (int i=0;i<allowedInterfaces.length;i++) {
 96                      if (credInterface.equals(allowedInterfaces[i])) {
 97                          allowedInterface = true;
 98                          break;
 99                      }
 100                 }
 101             }
 102             if (!allowedInterface || credInterface == null) {
 103                                 oneFailed = true;
 105             result.addErrorDetails(smh.getLocalString
 106                        ("tests.componentNameConstructor",
 107                     "For [ {0} ]",
 108                     new Object
  [] {compName.toString()})); 109         result.failed(smh.getLocalString
 110                     ("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.failed",
 111                     "Authentication mechanism credential interface [ {0} ] defined in the credential-interface tag is not allowed",
 112                     new Object
  [] {credInterface})); 113             }
 114         }
 115         if (!oneFailed) {
 116         result.addGoodDetails(smh.getLocalString
 117                        ("tests.componentNameConstructor",
 118                     "For [ {0} ]",
 119                     new Object
  [] {compName.toString()})); 120         result.passed(smh.getLocalString
 121                 ("com.sun.enterprise.tools.verifier.tests.connector.CredentialInterface.passed",
 122                  "All defined authorization mechanism credential interfaces are allowed"));
 123         }
 124         return result;
 125     }
 126 }
 127
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |