Exemplo n.º 1
0
 @BeforeSuite
 public void setUpTests() {
   OSCARSNetLogger netLogger = OSCARSNetLogger.getTlogger();
   netLogger.init(ModuleName.COORD, "0000");
   System.out.println("starting coordinator tests");
   cc.setContext(context);
   cc.setServiceName(ServiceNames.SVC_COORD);
   try {
     cc.loadManifest(new File("config/" + ConfigDefaults.MANIFEST));
     cc.setLog4j();
     // need to do this after the log4j.properties file has been set
     log = Logger.getLogger(CoordTest.class);
     log.debug(netLogger.start("setupTests"));
   } catch (ConfigException ex) {
     System.out.println("caught ConfigurationException " + ex.getMessage());
     System.exit(-1);
   }
 }
Exemplo n.º 2
0
  /**
   * @param args arg[0] -c cmd, [1] -u loginName or -s Subject DN, [2] -p password or -i Issuer DN
   *     [3] -C context
   * @throws Exception
   */
  public static void main(String args[]) throws Exception {

    parseArgs(args);

    cc.setContext(context);
    cc.setServiceName(ServiceNames.SVC_AUTHN);
    try {
      cc.loadManifest(ServiceNames.SVC_AUTHN, ConfigDefaults.MANIFEST); // manifest.yaml
      cc.setLog4j();
    } catch (ConfigException ex) {
      System.out.println("caught ConfigurationException " + ex.getMessage());
      System.exit(-1);
    }

    String configFile = cc.getFilePath(ConfigDefaults.CONFIG);
    Map config = ConfigHelper.getConfiguration(configFile);
    assert config != null : "No configuration";
    Map authN = (Map) config.get("soap");
    URL host = new URL((String) authN.get("publishTo"));
    URL wsdl = cc.getWSDLPath(null);
    System.out.println("host is " + host.toString() + "wsdl is " + wsdl.toString());
    AuthNClient client = AuthNClient.getClient(host, wsdl);

    if (cmd.equals("verifyLogin")) {
      System.out.println("Invoking verifyLogin...");
      if (loginName == null || password == null) {
        parser.printHelpOn(System.out);
        System.exit(0);
      }
      LoginId loginId = new LoginId();
      VerifyLoginReqType verifyLoginReq = new VerifyLoginReqType();
      loginId.setLoginName(loginName);
      loginId.setPassword(password);
      verifyLoginReq.setLoginId(loginId);
      verifyLoginReq.setTransactionId("0000");
      Object[] req = new Object[] {verifyLoginReq};

      try {
        Object[] res = client.invoke("verifyLogin", req);
        VerifyReply reply = (VerifyReply) res[0];
        SubjectAttributes subjectAttrs = reply.getSubjectAttributes();
        List<AttributeType> attrs = subjectAttrs.getSubjectAttribute();
        if (attrs.isEmpty()) {
          System.out.println("verifyLogin result= " + loginName + " has no attributes");
        } else {
          for (AttributeType at : attrs) {
            System.out.println(
                "verifyLogin.result=" + at.getName() + " : " + at.getAttributeValue());
          }
        }
      } catch (OSCARSServiceException ex) {
        System.out.println("OSCARSServiceException thrown; " + ex.getMessage());
        ErrorReport errReport = ex.getErrorReport();
        if (errReport != null) {
          System.out.println(errReport.toString());
        }
      }
    } else if (cmd.equals("verifyDN")) {
      System.out.println("Invoking verifyDN...");
      if (issuer == null || subject == null) {
        parser.printHelpOn(System.out);
        System.exit(0);
      }
      VerifyDNReqType verifyDNReq = new VerifyDNReqType();
      DNType DNReq = new DNType();
      DNReq.setSubjectDN(subject);
      DNReq.setIssuerDN(issuer);
      verifyDNReq.setTransactionId("123");
      verifyDNReq.setDN(DNReq);
      Object[] req = new Object[] {verifyDNReq};
      try {
        Object[] res = client.invoke("verifyDN", req);
        VerifyReply reply = (VerifyReply) res[0];
        SubjectAttributes subjectAttrs = reply.getSubjectAttributes();
        List<AttributeType> attrs = subjectAttrs.getSubjectAttribute();
        if (attrs.isEmpty()) {
          System.out.println("verifyDN result= user has no attributes");
        } else {
          for (AttributeType at : attrs) {
            System.out.println("verifyDN.result=" + at.getName() + " : " + at.getAttributeValue());
          }
        }
      } catch (OSCARSServiceException ex) {
        System.out.println("OSCARSServiceException thrown: " + ex.getMessage());
        ErrorReport errReport = ex.getErrorReport();
        if (errReport != null) {
          System.out.println(errReport.toString());
        }
      }
    } else {
      System.out.println("unrecognized command: " + cmd);
    }

    System.exit(0);
  }