Package org.apache.shindig.gadgets.oauth2

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


    return new OAuth2Arguments(AuthType.OAUTH2, map);
  }

  protected static List<ClientAuthenticationHandler> getDummyClientAuthHandlers() throws Exception {
    final List<ClientAuthenticationHandler> ret = new ArrayList<ClientAuthenticationHandler>(2);
    ret.add(new BasicAuthenticationHandler());
    ret.add(new StandardAuthenticationHandler());
    return ret;
  }
View Full Code Here


    String ret = null;

    final String grantType = accessor.getGrantType();

    GrantRequestHandler grantRequestHandlerUsed = null;
    for (final GrantRequestHandler grantRequestHandler : this.grantRequestHandlers) {
      if (grantRequestHandler.getGrantType().equalsIgnoreCase(grantType)) {
        grantRequestHandlerUsed = grantRequestHandler;
        break;
      }
    }

    if (grantRequestHandlerUsed == null) {
      accessor.setErrorResponse(null, OAuth2Error.AUTHENTICATION_PROBLEM,
              "no grantRequestHandler found for " + grantType, "");
    } else {
      String completeAuthUrl = null;
      try {
        completeAuthUrl = grantRequestHandlerUsed.getCompleteUrl(accessor);
      } catch (final OAuth2RequestException e) {
        if (isLogging) {
          BasicOAuth2Request.LOG.log("error getting complete url", e);
        }
      }
      if (grantRequestHandlerUsed.isRedirectRequired()) {
        ret = completeAuthUrl;
      } else {
        final OAuth2HandlerError error = this.authorize(accessor, grantRequestHandlerUsed,
                completeAuthUrl);
        if (error != null) {
View Full Code Here

      }

      boolean foundHandler = false;
      for (final AuthorizationEndpointResponseHandler authorizationEndpointResponseHandler : this.authorizationEndpointResponseHandlers) {
        if (authorizationEndpointResponseHandler.handlesRequest(accessor, request)) {
          final OAuth2HandlerError handlerError = authorizationEndpointResponseHandler
              .handleRequest(accessor, request);
          if (handlerError != null) {
            OAuth2CallbackServlet.sendError(handlerError.getError(),
                handlerError.getContextMessage(), null, accessor, resp, handlerError.getCause());
            return;
          }
          foundHandler = true;
          break;
        }
View Full Code Here

  }

  protected static List<ClientAuthenticationHandler> getDummyClientAuthHandlers() throws Exception {
    final List<ClientAuthenticationHandler> ret = new ArrayList<ClientAuthenticationHandler>(2);
    ret.add(new BasicAuthenticationHandler());
    ret.add(new StandardAuthenticationHandler());
    return ret;
  }
View Full Code Here

  }

  protected static List<TokenEndpointResponseHandler> getDummyTokenEndpointResponseHandlers()
      throws Exception {
    final List<TokenEndpointResponseHandler> ret = new ArrayList<TokenEndpointResponseHandler>(1);
    ret.add(new TokenAuthorizationResponseHandler(MockUtils.getDummyMessageProvider(), MockUtils
        .getDummyStore()));
    return ret;
  }
View Full Code Here

    return new DummySecurityToken(ownerId, viewerId, appUrl);
  }

  protected static OAuth2Store getDummyStore() throws Exception {
    if (MockUtils.dummyStore == null) {
      final OAuth2Cache cache = new InMemoryCache();
      final OAuth2Persister persister = MockUtils.getDummyPersister();
      MockUtils.dummyStore = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    }

    MockUtils.dummyStore.clearCache();
View Full Code Here

    return accessToken;
  }

  private static BasicOAuth2Accessor getOAuth2AccessorCommon() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

    return accessor;
  }

  protected static OAuth2Accessor getOAuth2Accessor_ClientCredentialsRedirecting() throws Exception {
    final OAuth2Cache cache = new InMemoryCache();
    final OAuth2Persister persister = MockUtils.getDummyPersister();
    final OAuth2Store store = MockUtils.getDummyStore(cache, persister, MockUtils.REDIRECT_URI);
    final BasicOAuth2Accessor accessor = new BasicOAuth2Accessor(MockUtils.GADGET_URI1,
        MockUtils.SERVICE_NAME, MockUtils.USER, MockUtils.SCOPE, true, store,
        MockUtils.REDIRECT_URI);
View Full Code Here

    client.setServiceName(MockUtils.SERVICE_NAME);
    client.setTokenUrl(MockUtils.TOKEN_URL);
  }

  protected static OAuth2Client getClient_Code_Confidential() throws Exception {
    final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter());
    MockUtils.setClientCommons(client);
    client.setClientAuthenticationType(OAuth2Message.BASIC_AUTH_TYPE);
    client.setClientId(MockUtils.CLIENT_ID1);
    client.setClientSecret(MockUtils.CLIENT_SECRET1.getBytes("UTF-8"));
    client.setGadgetUri(MockUtils.GADGET_URI1);
    client.setType(OAuth2Accessor.Type.CONFIDENTIAL);
    client.setAllowModuleOverride(true);
    client.setAuthorizationHeader(true);
    client.setUrlParameter(false);

    return client;
  }
View Full Code Here

    return client;
  }

  protected static OAuth2Client getClient_Code_Public() throws Exception {
    final OAuth2Client client = new OAuth2Client(MockUtils.getDummyEncrypter());
    MockUtils.setClientCommons(client);
    client.setClientAuthenticationType(OAuth2Message.STANDARD_AUTH_TYPE);
    client.setClientId(MockUtils.CLIENT_ID2);
    client.setClientSecret(MockUtils.CLIENT_SECRET2.getBytes("UTF-8"));
    client.setGadgetUri(MockUtils.GADGET_URI2);
    client.setType(OAuth2Accessor.Type.PUBLIC);
    client.setAllowModuleOverride(false);
    client.setAuthorizationHeader(false);
    client.setUrlParameter(true);

    return client;
  }
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.