Пример #1
0
  public static boolean matchesBinaryOperatorExpression(
      OperatorStatement os, BinaryOperatorExpression boe, InterpretationContext context) {

    if (os.getName().equals(boe.getOperator()) && os.isBinary()) {
      // types now have to match
      DNVariable leftArg = (DNVariable) os.getArgs().get(0);
      DNVariable rightArg = (DNVariable) os.getArgs().get(1);
      DNType leftArgT = context.getLibrary().getProgramDefinedOrLibraryDNTypeFor(leftArg.getType());
      DNType rightArgT =
          context.getLibrary().getProgramDefinedOrLibraryDNTypeFor(rightArg.getType());

      if (leftArgT.isEqualOrIsSuperType(boe.getLeftExpression().getDNType())
          && rightArgT.isEqualOrIsSuperType(boe.getRightExpression().getDNType())) {
        return true;
      }
    }
    return false;
  }
Пример #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);
  }