Examples of OAuth2Message


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

                "error exchanging code for access_token", e);
      }

      if (ret == null && response != null) {
        if (response.getHttpStatusCode() != HttpResponse.SC_OK) {
          final OAuth2Message msg = this.oauth2MessageProvider.get();
          msg.parseJSON(response.getResponseAsString());
          if (msg.getError() != null) {
            ret = new OAuth2HandlerError(msg.getError(), "error exchanging code for access_token",
                    null);
          }
        }

        if (ret == null) {
View Full Code Here

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

  protected void doGet(final HttpServletRequest request, final HttpServletResponse resp)
          throws IOException {

    OAuth2Accessor accessor = null;
    try {
      final OAuth2Message msg = this.oauth2MessageProvider.get();
      msg.parseRequest(request);
      final OAuth2Error error = msg.getError();
      final String encRequestStateKey = msg.getState();
      if (encRequestStateKey == null) {
        if (error != null) {
          OAuth2CallbackServlet.sendError(error, msg.getErrorDescription(), msg.getErrorUri(),
                  null, resp, null);
        } else {
          OAuth2CallbackServlet.sendError(OAuth2Error.CALLBACK_PROBLEM,
                  "OAuth2CallbackServlet requestStateKey is null.", "", null, resp, null);
        }
        return;
      }

      final OAuth2CallbackState state = new OAuth2CallbackState(this.stateCrypter,
              encRequestStateKey);

      accessor = this.store.getOAuth2Accessor(state);

      if (error != null) {
        OAuth2CallbackServlet.sendError(error, msg.getErrorDescription(), msg.getErrorUri(),
                accessor, resp, null);
        return;
      }

      if (accessor == null || !accessor.isValid() || accessor.isErrorResponse()) {
View Full Code Here

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

        if (ret == null) {
          final long issuedAt = System.currentTimeMillis();

          final String contentType = response.getHeader("Content-Type");
          final String responseString = response.getResponseAsString();
          final OAuth2Message msg = this.oauth2MessageProvider.get();

          if (contentType.startsWith("text/plain")) {
            // Facebook does this
            msg.parseQuery('?' + responseString);
          } else if (contentType.startsWith("application/json")) {
            // Google does this
            final JSONObject responseJson = new JSONObject(responseString);
            msg.parseJSON(responseJson.toString());
          } else {
            if (isLogging) {
              TokenAuthorizationResponseHandler.LOG.log("Unhandled Content-Type {0}", contentType);
              TokenAuthorizationResponseHandler.LOG.exiting(
                      TokenAuthorizationResponseHandler.LOG_CLASS, "handleResponse", null);
            }
            ret = TokenAuthorizationResponseHandler.getError("Unhandled Content-Type "
                    + contentType);
          }

          final OAuth2Error error = msg.getError();
          if (error == null && accessor != null) {
            final String accessToken = msg.getAccessToken();
            final String refreshToken = msg.getRefreshToken();
            final String expiresIn = msg.getExpiresIn();
            final String tokenType = msg.getTokenType();
            final String providerName = accessor.getServiceName();
            final String gadgetUri = accessor.getGadgetUri();
            final String scope = accessor.getScope();
            final String user = accessor.getUser();
            final String macAlgorithm = msg.getMacAlgorithm();
            final String macSecret = msg.getMacSecret();
            final Map<String, String> unparsedProperties = msg.getUnparsedProperties();

            if (accessToken != null) {
              final OAuth2Token storedAccessToken = this.store.createToken();
              storedAccessToken.setIssuedAt(issuedAt);
              if (expiresIn != null) {
View Full Code Here

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

              "grant_type is not code", null);
    }

    if (ret == null) {
      try {
        final OAuth2Message msg = this.oauth2MessageProvider.get();
        msg.parseRequest(request);

        ret = this.setAuthorizationCode(msg.getAuthorization(), accessor);
      } catch (final Exception e) {
        if (CodeAuthorizationResponseHandler.LOG.isLoggable()) {
          CodeAuthorizationResponseHandler.LOG.log(
                  "Exception exchanging authorization code for access_token", e);
        }
View Full Code Here

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

                "error exchanging code for access_token", e);
      }

      if (ret == null && response != null) {
        if (response.getHttpStatusCode() != HttpResponse.SC_OK) {
          final OAuth2Message msg = this.oauth2MessageProvider.get();
          msg.parseJSON(response.getResponseAsString());
          if (msg.getError() != null) {
            ret = new OAuth2HandlerError(msg.getError(), "error exchanging code for access_token",
                    null);
          }
        }

        if (ret == null) {
View Full Code Here

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

  protected void doGet(final HttpServletRequest request, final HttpServletResponse resp)
          throws IOException {

    OAuth2Accessor accessor = null;
    try {
      final OAuth2Message msg = this.oauth2MessageProvider.get();
      msg.parseRequest(request);
      final OAuth2Error error = msg.getError();
      final String encRequestStateKey = msg.getState();
      if (encRequestStateKey == null) {
        if (error != null) {
          OAuth2CallbackServlet.sendError(error, "encRequestStateKey is null", msg.getErrorDescription(),
                  msg.getErrorUri(), null, resp, null, this.sendTraceToClient);
        } else {
          OAuth2CallbackServlet.sendError(OAuth2Error.CALLBACK_PROBLEM,
                  "OAuth2CallbackServlet requestStateKey is null.", "", "", null, resp, null,
                  this.sendTraceToClient);
        }
        return;
      }

      final OAuth2CallbackState state = new OAuth2CallbackState(this.stateCrypter,
              encRequestStateKey);

      accessor = this.store.getOAuth2Accessor(state);

      if (error != null) {
        OAuth2CallbackServlet.sendError(error, "error parsing request", msg.getErrorDescription(),
                msg.getErrorUri(), accessor, resp, null, this.sendTraceToClient);
        return;
      }

      if (accessor == null || !accessor.isValid() || accessor.isErrorResponse()) {
        String message;
View Full Code Here

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

              "grant_type is not code", null);
    }

    if (ret == null) {
      try {
        final OAuth2Message msg = this.oauth2MessageProvider.get();
        msg.parseRequest(request);
        if (msg.getError() != null) {
          ret = new OAuth2HandlerError(msg.getError(), "error parsing authorization response",
                  null, msg.getErrorUri(), msg.getErrorDescription());
        } else {
          ret = this.setAuthorizationCode(msg.getAuthorization(), accessor);
        }
      } catch (final Exception e) {
        if (CodeAuthorizationResponseHandler.LOG.isLoggable()) {
          CodeAuthorizationResponseHandler.LOG.log(
                  "Exception exchanging authorization code for access_token", e);
View Full Code Here

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

                "error exchanging code for access_token", e);
      }

      if (ret == null && response != null) {
        if (response.getHttpStatusCode() != HttpResponse.SC_OK) {
          final OAuth2Message msg = this.oauth2MessageProvider.get();
          msg.parseJSON(response.getResponseAsString());
          if (msg.getError() != null) {
            ret = new OAuth2HandlerError(msg.getError(), "error exchanging code for access_token",
                    null, msg.getErrorUri(), msg.getErrorDescription());
          }
        }

        if (ret == null) {
          for (final TokenEndpointResponseHandler tokenEndpointResponseHandler : this.tokenEndpointResponseHandlers) {
View Full Code Here

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

        if (ret == null) {
          final long issuedAt = System.currentTimeMillis();

          final String contentType = response.getHeader("Content-Type");
          final String responseString = response.getResponseAsString();
          final OAuth2Message msg = this.oauth2MessageProvider.get();

          if (isLogging) {
            TokenAuthorizationResponseHandler.LOG.log("Content-Type {0}", contentType);
            TokenAuthorizationResponseHandler.LOG.log("Response String {0}", responseString);
          }
          if (contentType.startsWith("application/json")) {
            // Google does this
            final JSONObject responseJson = new JSONObject(responseString);
            msg.parseJSON(responseJson.toString());
          } else {
            // Default assume it is application/x-www-form-urlencoded
            // Facebook has a content type of text/plain
            // GitHub has a content type of application/x-www-form-urlencoded
            msg.parseQuery('?' + responseString);
          }

          final OAuth2Error error = msg.getError();
          if (error != null) {
            ret = getError("error parsing request", null, msg.getErrorUri(),
                    msg.getErrorDescription());
          } else if (error == null && accessor != null) {
            final String accessToken = msg.getAccessToken();
            final String refreshToken = msg.getRefreshToken();
            final String expiresIn = msg.getExpiresIn();
            final String tokenType = msg.getTokenType();
            final String providerName = accessor.getServiceName();
            final String gadgetUri = accessor.getGadgetUri();
            final String scope = accessor.getScope();
            final String user = accessor.getUser();
            final String macAlgorithm = msg.getMacAlgorithm();
            final String macSecret = msg.getMacSecret();
            final Map<String, String> unparsedProperties = msg.getUnparsedProperties();

            if (accessToken != null) {
              final OAuth2Token storedAccessToken = this.store.createToken();
              storedAccessToken.setIssuedAt(issuedAt);
              if (expiresIn != null) {
View Full Code Here

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

              "grant_type is not code", null);
    }

    if (ret == null) {
      try {
        final OAuth2Message msg = this.oauth2MessageProvider.get();
        msg.parseRequest(request);
        if (msg.getError() != null) {
          ret = new OAuth2HandlerError(msg.getError(), "error parsing authorization response",
                  null, msg.getErrorUri(), msg.getErrorDescription());
        } else {
          ret = this.setAuthorizationCode(msg.getAuthorization(), accessor);
        }
      } catch (final Exception e) {
        if (CodeAuthorizationResponseHandler.LOG.isLoggable()) {
          CodeAuthorizationResponseHandler.LOG.log(
                  "Exception exchanging authorization code for access_token", 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.