Package org.opensocial.auth

Examples of org.opensocial.auth.OAuth3LeggedScheme$Token


  @Override
  protected void onListItemClick(ListView listView, View view, int position,
      long id) {
    final String providerName = providers[position];
    final OAuth3LeggedScheme authScheme = getAuth(providerName);

    if (authScheme != null) {
      final AlertDialog alert = new AlertDialog.Builder(this).create();
      alert.setMessage("To get started, you will need to login to " + providerName);
      alert.setButton("Login", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          alert.dismiss();

          String url = null;
          try {
            url = authScheme.getAuthorizationUrl(scheme + "://");
            persistRequestToken(authScheme.getRequestToken(), providerName);
          } catch (IOException e) {
            throw new RuntimeException("Error occured fetching request token: " + e.getMessage(), e);
          } catch (URISyntaxException e) {
            throw new RuntimeException("Error occured fetching request token", e);
          } catch (OAuthException e) {
View Full Code Here


    }

    try {
      Provider provider = providerClass.newInstance();

      return new OAuth3LeggedScheme(provider, credentials[0], credentials[1]);
    } catch (InstantiationException e) {
      return null;
    } catch (IllegalAccessException e) {
      return null;
    }
View Full Code Here

    String verifierParam = request.getParameter("oauth_verifier");
    String tokenParam = request.getParameter("oauth_token");
    boolean authFlag = false;

    OAuth3LeggedScheme scheme = null;
    if (session != null) {
      scheme = (OAuth3LeggedScheme) session.getAttribute(SCHEME_KEY);
    }

    if (scheme == null) {
      authFlag = true;
    } else {
      if (scheme.getAccessToken() != null) {
        chain.doFilter(req, resp);
      } else if (scheme.getRequestToken() != null && tokenParam != null) {
        try {
          scheme.requestAccessToken(tokenParam, verifierParam);
          session.setAttribute(SCHEME_KEY, scheme);
          response.sendRedirect(request.getRequestURL().toString());
        } catch (Exception e) {
          e.printStackTrace();
        }
      } else {
        authFlag = true;
      }
    }

    if (authFlag) {
      scheme = new OAuth3LeggedScheme(new GoogleProvider(), GOOGLE_KEY,
          GOOGLE_SECRET);
      //scheme = new OAuth3LeggedScheme(new YahooProvider(), YAHOO_KEY,
          //YAHOO_SECRET);

      try {
        String authUrl =
          scheme.getAuthorizationUrl(request.getRequestURL().toString());
        session.setAttribute(SCHEME_KEY, scheme);
        response.sendRedirect(authUrl);
      } catch (Exception e) {
        e.printStackTrace();
      }
View Full Code Here

  }

  @Before
  public void setUp() throws Exception {
    if (client.getAuthScheme() instanceof OAuth3LeggedScheme) {
      OAuth3LeggedScheme scheme = (OAuth3LeggedScheme) client.getAuthScheme();
      // for 3-legged OAuth, ignore the process to get access token
      Token token = new Token("key", "secret");
      scheme.setAccessToken(token);
    }

    clear();
  }
View Full Code Here

  public static class Orkut3LeggedRpcTest extends BaseRequestTest {
    @BeforeClass
    public static void init() {
      Provider p = new OrkutProvider(false);
      client = new Client(p, new OAuth3LeggedScheme(p, "consumerKey",
          "consumerSecret"));
    }
View Full Code Here

  public static class Orkut3LeggedRestTest extends BaseRequestTest {
    @BeforeClass
    public static void init() {
      Provider p = new OrkutProvider(true);
      client = new Client(p, new OAuth3LeggedScheme(p, "consumerKey",
          "consumerSecret"));
    }
View Full Code Here

        client.listTenants(fakeToken);
    }

    private KeystoneAuthenticationToken buildFakeToken(String tokenCode) {
        Access auth = new Access();
        Token tokenObject = new Token();
        tokenObject.setId(tokenCode);
        auth.setToken(tokenObject);
        return new KeystoneAuthenticationToken(auth);
    }
View Full Code Here

TOP

Related Classes of org.opensocial.auth.OAuth3LeggedScheme$Token

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.