Examples of TokenState


Examples of co.cask.cdap.security.auth.TokenState

    }

    logEntry.setClientIP(((InetSocketAddress) ctx.getChannel().getRemoteAddress()).getAddress());
    logEntry.setRequestLine(msg.getMethod(), msg.getUri(), msg.getProtocolVersion());

    TokenState tokenState = tokenValidator.validate(accessToken);
    if (!tokenState.isValid()) {
      HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.UNAUTHORIZED);
      logEntry.setResponseCode(HttpResponseStatus.UNAUTHORIZED.getCode());

      JsonObject jsonObject = new JsonObject();
      if (tokenState == TokenState.MISSING) {
        httpResponse.addHeader(HttpHeaders.Names.WWW_AUTHENTICATE,
                                 String.format("Bearer realm=\"%s\"", realm));
        LOG.debug("Authentication failed due to missing token");

      } else {
        httpResponse.addHeader(HttpHeaders.Names.WWW_AUTHENTICATE,
                                 String.format("Bearer realm=\"%s\" error=\"invalid_token\"" +
                                                 " error_description=\"%s\"", realm, tokenState.getMsg()));
        jsonObject.addProperty("error", "invalid_token");
        jsonObject.addProperty("error_description", tokenState.getMsg());
        LOG.debug("Authentication failed due to invalid token, reason={};", tokenState);
      }
      JsonArray externalAuthenticationURIs = new JsonArray();

      //Waiting for service to get discovered
View Full Code Here

Examples of fasp.parser.tokenizer.TokenState

    return new GroundRegularRule(head, bodyElts, bodyOp);
  }

  // Parse the result of the CSP solver
  public static GroundLiteral parseLiteral(String str) throws Exception {
    NonGroundLiteral lit = new LiteralParser().parse(new TokenState(str));
    Map<FaspVariable, FaspConstant> constMap = new HashMap<FaspVariable, FaspConstant>();
    return lit.ground(constMap);
  }
View Full Code Here

Examples of fasp.parser.tokenizer.TokenState

    return new GroundRegularRule(head, bodyElts, bodyOp);
  }

  // Parse the result of the CSP solver
  public static GroundLiteral parseLiteral(String str) throws Exception {
    NonGroundLiteral lit = new LiteralParser().parse(new TokenState(str));
    Map<FaspVariable, FaspConstant> constMap = new HashMap<FaspVariable, FaspConstant>();
    return lit.ground(constMap);
  }
View Full Code Here

Examples of fasp.parser.tokenizer.TokenState

    if(args.length >= 2) {
      if(args[0].equals("-g")) {
        readFile(args[1],new FileAction() {
          public void act(String str) {
            try {
              TokenState st = new TokenState(str);
              NonGroundProgram ngProg = new ProgramParser().parse(st);
              GroundProgram groundProg = ngProg.ground();
              System.out.println(groundProg);
              //System.out.println(groundProg.filterGrounding());
            } catch (ParseException e) {
              System.out.println(e.getParseError());
            }
          }
        });
      } else if(args[0].equals("-c") && args.length == 3) {
        Double lowerBound;
        try {
          lowerBound = Double.parseDouble(args[1]);
          if(lowerBound >= 0 && lowerBound <= 1)
            readFile(args[2],new CompletionAction(lowerBound));
          else
            System.out.println("The y-argument should be in [0,1]");
        } catch (NumberFormatException e) {
          System.out.println("ERROR: the second argument of -c was not a Double.");
          printUsage();
        }
      } else if(args[0].equals("-s")) {
        System.out.println("Not implemented yet!");
      } else if(args[0].equals("-im")) {
        readFile(args[1],new FileAction() {
          // TODO: remove duplication of code in this action and the
          // grounding action (i.e. have a separate groundingaction that
          // can be called that returns a GroundProgram).
          public void act(String str) {
            try {
              TokenState st = new TokenState(str);
              NonGroundProgram ngProg = new ProgramParser().parse(st);
              GroundProgram groundProg = ngProg.ground();
              ConsequenceOp imcons = new ConsequenceOp(groundProg);
              FaspInterpretation model = imcons.computeLFP();
              System.out.println("LFP Model:");
View Full Code Here

Examples of fasp.parser.tokenizer.TokenState

    public CompletionAction(Double d) {
      this.lowerBound = d;
    }
    public void act(String str) {
      try {
        TokenState st = new TokenState(str);
        NonGroundProgram ngProg = new ProgramParser().parse(st);
        GroundProgram groundProg = ngProg.ground();
        List<FuzzyLiteral> completion = groundProg.createCompletion(lowerBound);
        System.out.println(completion);
      } catch (ParseException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.