Examples of OAuth2RequestException


Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

    this.macSecret = secret;
    if (this.encrypter != null) {
      try {
        this.encryptedMacSecret = this.encrypter.encrypt(secret);
      } catch (final OAuth2EncryptionException e) {
        throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM,
                "OAuth2TokenPersistence could not encrypt the mac secret", e);
      }
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  public void setSecret(final byte[] secret) throws OAuth2RequestException {
    this.secret = secret;
    try {
      this.encryptedSecret = this.encrypter.encrypt(secret);
    } catch (final OAuth2EncryptionException e) {
      throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM,
              "OAuth2TokenPersistence could not encrypt the token secret", e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

    final byte[] secretBytes = accessor.getClientSecret();
    String secret;
    try {
      secret = new String(secretBytes, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "error getting authorization body", e);
    }
    queryParams.put(OAuth2Message.CLIENT_ID, clientId);
    queryParams.put(OAuth2Message.CLIENT_SECRET, secret);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  public HttpRequest getAuthorizationRequest(final OAuth2Accessor accessor,
          final String completeAuthorizationUrl) throws OAuth2RequestException {

    if ((completeAuthorizationUrl == null) || (completeAuthorizationUrl.length() == 0)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "completeAuthorizationUrl is null", null);
    }

    if (accessor == null) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null",
              null);
    }

    if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "accessor is invalid", null);
    }

    if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.CLIENT_CREDENTIALS)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "grant type is not client_credentials", null);
    }

    final HttpRequest request = new HttpRequest(Uri.parse(completeAuthorizationUrl));
    request.setMethod("GET");
    request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    request.setSecurityToken( new AnonymousSecurityToken( "", 0L, accessor.getGadgetUri(), 0L ));

    for (final ClientAuthenticationHandler clientAuthenticationHandler : this.clientAuthenticationHandlers) {
      if (clientAuthenticationHandler.geClientAuthenticationType().equalsIgnoreCase(
              accessor.getClientAuthenticationType())) {
        final OAuth2HandlerError error = clientAuthenticationHandler.addOAuth2Authentication(
                request, accessor);
        if (error != null) {
          throw new OAuth2RequestException(error.getError(), error.getContextMessage(),
                  error.getCause());
        }
      }
    }

    try {
      request.setPostBody(this.getAuthorizationBody(accessor).getBytes("UTF-8"));
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "ClientCredentialsGrantTypeHandler - exception setting post body", e);
    }

    return request;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  }

  public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException {

    if (accessor == null) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null",
              null);
    }

    if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "accessor is invalid", null);
    }

    if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.CLIENT_CREDENTIALS)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "grant type is not client_credentials", null);
    }

    String ret;
    try {
      final Map<String, String> queryParams = Maps.newHashMapWithExpectedSize(4);
      queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType());

      final String clientId = accessor.getClientId();
      final byte[] secretBytes = accessor.getClientSecret();
      final String secret = new String(secretBytes, "UTF-8");
      queryParams.put(OAuth2Message.CLIENT_ID, clientId);
      queryParams.put(OAuth2Message.CLIENT_SECRET, secret);

      final String scope = accessor.getScope();
      if ((scope != null) && (scope.length() > 0)) {
        queryParams.put(OAuth2Message.SCOPE, scope);
      }

      ret = OAuth2Utils.buildUrl(accessor.getTokenUrl(), queryParams, null);
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "problem getting complete url", e);
    }

    return ret;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

    final byte[] secretBytes = accessor.getClientSecret();
    String secret;
    try {
      secret = new String(secretBytes, "UTF-8");
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "error getting authorization body", e);
    }
    queryParams.put(OAuth2Message.CLIENT_ID, clientId);
    queryParams.put(OAuth2Message.CLIENT_SECRET, secret);
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  public HttpRequest getAuthorizationRequest(final OAuth2Accessor accessor,
          final String completeAuthorizationUrl) throws OAuth2RequestException {

    if ((completeAuthorizationUrl == null) || (completeAuthorizationUrl.length() == 0)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "completeAuthorizationUrl is null", null);
    }

    if (accessor == null) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null",
              null);
    }

    if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "accessor is invalid", null);
    }

    if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.CLIENT_CREDENTIALS)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "grant type is not client_credentials", null);
    }

    final HttpRequest request = new HttpRequest(Uri.parse(completeAuthorizationUrl));
    request.setMethod("GET");
    request.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
    request.setSecurityToken( new AnonymousSecurityToken( "", 0L, accessor.getGadgetUri()));

    for (final ClientAuthenticationHandler clientAuthenticationHandler : this.clientAuthenticationHandlers) {
      if (clientAuthenticationHandler.geClientAuthenticationType().equalsIgnoreCase(
              accessor.getClientAuthenticationType())) {
        final OAuth2HandlerError error = clientAuthenticationHandler.addOAuth2Authentication(
                request, accessor);
        if (error != null) {
          throw new OAuth2RequestException(error.getError(), error.getContextMessage(),
                  error.getCause());
        }
      }
    }

    try {
      request.setPostBody(this.getAuthorizationBody(accessor).getBytes("UTF-8"));
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "ClientCredentialsGrantTypeHandler - exception setting post body", e);
    }

    return request;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  }

  public String getCompleteUrl(final OAuth2Accessor accessor) throws OAuth2RequestException {

    if (accessor == null) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR, "accessor is null",
              null);
    }

    if (!accessor.isValid() || accessor.isErrorResponse() || accessor.isRedirecting()) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "accessor is invalid", null);
    }

    if (!accessor.getGrantType().equalsIgnoreCase(OAuth2Message.CLIENT_CREDENTIALS)) {
      throw new OAuth2RequestException(ClientCredentialsGrantTypeHandler.ERROR,
              "grant type is not client_credentials", null);
    }

    String ret;
    try {
      final Map<String, String> queryParams = Maps.newHashMapWithExpectedSize(4);
      queryParams.put(OAuth2Message.GRANT_TYPE, this.getGrantType());

      final String clientId = accessor.getClientId();
      final byte[] secretBytes = accessor.getClientSecret();
      final String secret = new String(secretBytes, "UTF-8");
      queryParams.put(OAuth2Message.CLIENT_ID, clientId);
      queryParams.put(OAuth2Message.CLIENT_SECRET, secret);

      final String scope = accessor.getScope();
      if ((scope != null) && (scope.length() > 0)) {
        queryParams.put(OAuth2Message.SCOPE, scope);
      }

      ret = OAuth2Utils.buildUrl(accessor.getTokenUrl(), queryParams, null);
    } catch (final UnsupportedEncodingException e) {
      throw new OAuth2RequestException(OAuth2Error.CLIENT_CREDENTIALS_PROBLEM,
              "problem getting complete url", e);
    }

    return ret;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  public void setMacSecret(final byte[] secret) throws OAuth2RequestException {
    this.macSecret = secret;
    try {
      this.encryptedMacSecret = this.encrypter == null ? secret : this.encrypter.encrypt(secret);
    } catch (final OAuth2EncryptionException e) {
      throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM,
              "OAuth2TokenPersistence could not encrypt the mac secret", e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.oauth2.OAuth2RequestException

  public void setSecret(final byte[] secret) throws OAuth2RequestException {
    this.secret = secret;
    try {
      this.encryptedSecret = this.encrypter == null ? secret : this.encrypter.encrypt(secret);
    } catch (final OAuth2EncryptionException e) {
      throw new OAuth2RequestException(OAuth2Error.SECRET_ENCRYPTION_PROBLEM,
              "OAuth2TokenPersistence could not encrypt the token secret", 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.