public void acceptRepresentation(final Representation entity) throws ResourceException {
   final Form form = getRequest().getEntityAsForm();
   final String serviceUrl = form.getFirstValue("serviceTicketUrl");
   try {
     final Assertion authentication =
         this.centralAuthenticationService.validateServiceTicket(
             serviceTicketId, new SimpleWebApplicationServiceImpl(serviceUrl, this.httpClient));
     if (authentication.getChainedAuthentications().size() > 0) {
       // Iterate through each of the ChainedAuthentications and put them into the JSonArray
       JSONArray jsonResult = new JSONArray();
       for (Authentication auth : authentication.getChainedAuthentications()) {
         // Create the principle
         JSONObject principle = createJSONPrinciple(auth);
         JSONObject jsonAuth = new JSONObject();
         jsonAuth.put("authenticated_date", auth.getAuthenticatedDate());
         jsonAuth.put("attributes", principle);
         jsonResult.add(jsonAuth);
       }
       getResponse().setEntity(jsonResult.toJSONString(), MediaType.TEXT_PLAIN);
     } else {
       getResponse()
           .setEntity(
               java.lang.String.format("\"{\"authenticated\":\"false\"}\""), MediaType.TEXT_PLAIN);
     }
   } catch (final TicketException e) {
     log.error(e.getMessage(), e);
     getResponse()
         .setStatus(Status.CLIENT_ERROR_NOT_FOUND, "TicketGrantingTicket could not be found.");
   } catch (final Exception e) {
     log.error(e.getMessage(), e);
     getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage());
   }
 }
Example #2
0
 public static EquipLogStatus findByCode(final int code) {
   if ($CODE_LOOKUP.containsKey(code)) {
     return $CODE_LOOKUP.get(code);
   }
   throw new java.lang.IllegalArgumentException(
       java.lang.String.format(
           "Enumeration 'EquipLogStatus' has no value for 'code = %s'", code));
 }
Example #3
0
 public Super(org.python.Object klass, org.python.Object instance) {
   try {
     this.klass = (org.python.types.Type) klass;
   } catch (java.lang.ClassCastException e) {
     throw new org.python.exceptions.TypeError(
         java.lang.String.format("must be type, not %s", klass.typeName()));
   }
   this.instance = instance;
 }
Example #4
0
  public static PrimitiveType get(Token tkn) throws SemanticErrorException {

    String name = tkn.getLexema();
    if (name.equals(PrimitiveType.Int.Name)) return PrimitiveType.Int;
    if (name.equals(PrimitiveType.String.Name)) return PrimitiveType.String;
    if (name.equals(PrimitiveType.Boolean.Name)) return PrimitiveType.Boolean;
    if (name.equals(PrimitiveType.Char.Name)) return PrimitiveType.Char;

    throw new SemanticErrorException(
        java.lang.String.format(
            "Error(!). Tipo primitivo invalido: %s. Linea %d", name, tkn.getLinea()));
  }
Example #5
0
 /** Utility method used by <code>Char.show</code> to quote a character. */
 public static final java.lang.String quoteChr(char c) {
   java.lang.StringBuilder sr = new java.lang.StringBuilder(8);
   sr.append("'");
   if (c < ' ' || c == '\177') {
     sr.append('\\');
     sr.append(java.lang.String.format("%o", (int) c));
   } else if (c == '\\' || c == '\'') {
     sr.append('\\');
     sr.append(c);
   } else sr.append(c);
   sr.append("'");
   return sr.toString();
 }
Example #6
0
 /** Utility method used by <code>String.show</code> to quote a string. */
 public static final java.lang.String quoteStr(java.lang.String a) {
   java.lang.StringBuilder sr = new java.lang.StringBuilder(2 + ((5 * a.length()) >> 2));
   sr.append('"');
   int i = 0;
   char c;
   while (i < a.length()) {
     c = a.charAt(i++);
     if (c < ' ' || c == '\177') {
       sr.append('\\');
       sr.append(java.lang.String.format("%o", (int) c));
     } else if (c == '\\' || c == '"') {
       sr.append('\\');
       sr.append(c);
     } else sr.append(c);
   }
   sr.append('"');
   return sr.toString();
 }