Exemplo n.º 1
0
 /**
  * Parses the response for a token request.
  *
  * <p>Throws a {@link TokenError} when the response indicates an error, or when the response could
  * not be properly parsed.
  *
  * <p>Some OAuth implementations may uses a non-standard encoding of the token.
  */
 protected OAuthAccessToken parseTokenResponse(HttpMessage response) {
   if (response.getStatus() == 200 || response.getStatus() == 400) {
     String type = response.getHeader("Content-Type");
     if (type != null) {
       if (type.startsWith("text/plain; charset=UTF-8")) {
         return this.parseUrlEncodedToken(response);
       } else {
         if (type.startsWith("application/json")) {
           return this.parseJsonToken(response);
         } else {
           throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
         }
       }
     } else {
       throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
     }
   } else {
     throw new OAuthProcess.TokenError(WString.tr("Wt.Auth.OAuthService.badresponse"));
   }
 }