Package com.ibm.sbt.security.authentication.oauth.consumer

Examples of com.ibm.sbt.security.authentication.oauth.consumer.OAuth1Handler


  public void execHttpSession() throws ServletException, IOException {
    Context context = Context.get();

    // Find the OAuth dance object being used
    OAuth1Handler oAuthHandler = (OAuth1Handler)context.getSessionMap().get(Configuration.OAUTH1_HANDLER);
    if (oAuthHandler == null) {
      throw new ServletException(
          "Internal Error: Cannot find the OAuth object back from the request");
    }

    // Read the oauth parameters
    try {
      String oauth_token = (String) context.getRequestParameterMap().get(OAConstants.OAUTH_TOKEN);
      String oauth_verifier = (String) context.getRequestParameterMap().get(OAConstants.OAUTH_VERIFIER);
     
      oAuthHandler.setAccessToken(oauth_token);
      oAuthHandler.setVerifierCode(oauth_verifier);
     
      AccessToken tk = oAuthHandler.readToken(oauth_token, oauth_verifier);
      if (tk == null) {
        // should not happen
        throw new ServletException("Missing OAuth token");
      }
      // Store the new key
      oAuthHandler.setAccessTokenObject(tk);
      if (!context.isCurrentUserAnonymous()) {
        CredentialStore cs = CredentialStoreFactory.getCredentialStore(oAuthHandler.getCredentialStore());
        if (cs != null) {
          // But we store it uniquely if the current user is not anonymous
          cs.store(oAuthHandler.getServiceName(), OAuth1Handler.ACCESS_TOKEN_STORE_TYPE, context.getCurrentUserId(), tk);
        }
      } else {
        AnonymousCredentialStore.storeCredentials(context, tk,
            oAuthHandler.getAppId(), oAuthHandler.getServiceName());
      }

      // redirect to the initial page
      String applicationPage = oAuthHandler.getApplicationPage();
      if (StringUtil.isNotEmpty(applicationPage)) {
        context.sendRedirect(applicationPage);
      }
    } catch (Exception e) {
      throw new ServletException(e);
View Full Code Here


public class OAuthEndpoint extends AbstractEndpoint {

  protected OAuth1Handler  oAuthHandler;
 
  public OAuthEndpoint(){
    this.oAuthHandler = new OAuth1Handler();
  }
View Full Code Here

TOP

Related Classes of com.ibm.sbt.security.authentication.oauth.consumer.OAuth1Handler

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.