Package org.apache.shindig.gadgets.oauth2

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


  @Test
  public void testGetError_1() throws Exception {
    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
        "", new Exception());

    final OAuth2Error result = fixture.getError();

    Assert.assertNotNull(result);
    Assert.assertEquals("authentication_problem", result.getErrorCode());
    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name());
    Assert.assertEquals(2, result.ordinal());
    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString());
  }
View Full Code Here


    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);
View Full Code Here

            }
            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();
View Full Code Here

    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);
View Full Code Here

            // 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();
View Full Code Here

            }
            ret = TokenAuthorizationResponseHandler.getError("Unhandled Content-Type "
                    + contentType);
          }

          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();
View Full Code Here

import org.junit.Test;

public class OAuth2HandlerErrorTest {
  @Test
  public void testOAuth2HandlerError1() throws Exception {
    final OAuth2Error error = OAuth2Error.AUTHENTICATION_PROBLEM;
    final String contextMessage = "";
    final Exception cause = new Exception();

    final OAuth2HandlerError result = new OAuth2HandlerError(error, contextMessage, cause);
View Full Code Here

  @Test
  public void testGetError1() throws Exception {
    final OAuth2HandlerError fixture = new OAuth2HandlerError(OAuth2Error.AUTHENTICATION_PROBLEM,
            "", new Exception());

    final OAuth2Error result = fixture.getError();

    Assert.assertNotNull(result);
    Assert.assertEquals("authentication_problem", result.getErrorCode());
    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.name());
    Assert.assertEquals(2, result.ordinal());
    Assert.assertEquals("AUTHENTICATION_PROBLEM", result.toString());
  }
View Full Code Here

    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.getErrorUri(),
                  msg.getErrorDescription(), null, resp, null, this.sendTraceToClient);
View Full Code Here

  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 requestStateKey = msg.getState();
      if (requestStateKey == 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 Integer index = Integer.decode(requestStateKey);
      accessor = this.store.getOAuth2Accessor(index);

      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

TOP

Related Classes of org.apache.shindig.gadgets.oauth2.OAuth2Error

Copyright © 2018 www.massapicom. 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.