Examples of OAuthService


Examples of org.apache.shindig.gadgets.spec.OAuthService

    if (oauthSpec == null) {
      throw new OAuthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "Failed to retrieve OAuth URLs, spec for gadget " +
          securityToken.getAppUrl() + " does not contain OAuth element.");
    }
    OAuthService service = oauthSpec.getServices().get(arguments.getServiceName());
    if (service == null) {
      throw new OAuthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "Failed to retrieve OAuth URLs, spec for gadget does not contain OAuth service " +
          arguments.getServiceName() + ".  Known services: " +
          StringUtils.join(oauthSpec.getServices().keySet(), ',') + '.');
    }
    // In theory some one could specify different parameter locations for request token and
    // access token requests, but that's probably not useful.  We just use the request token
    // rules for everything.
    accessorBuilder.setParameterLocation(
        getStoreLocation(service.getRequestUrl().location, responseParams));
    accessorBuilder.setMethod(getStoreMethod(service.getRequestUrl().method, responseParams));
    return new OAuthServiceProvider(
        service.getRequestUrl().url.toJavaUri().toASCIIString(),
        service.getAuthorizationUrl().toJavaUri().toASCIIString(),
        service.getAccessUrl().url.toJavaUri().toASCIIString());
  }
View Full Code Here

Examples of org.eclipse.egit.github.core.service.OAuthService

    }

    private static GitHubClient createClient(String user, String pass) throws Exception {
        GitHubClient cliente = new GitHubClient();
        cliente.setCredentials(user, pass);
        OAuthService oauth = new OAuthService(cliente);
        Authorization auth = new Authorization();

        try {
            String token;
            if (oauth.getAuthorizations() == null || oauth.getAuthorizations().isEmpty()) {
                auth = oauth.createAuthorization(auth);
                token = auth.getToken();
                System.out.println("autorizooou: " + token);
            } else {
                List<Authorization> auths = oauth.getAuthorizations();
                System.out.println("autorizaçoes: " + auths.size());
                System.out.println("autorização: " + auths.get(0));
                token = auths.get(0).getToken();
                System.out.println("token: " + token);
            }
View Full Code Here

Examples of org.jboss.seam.social.oauth.OAuthService

        String authorizationUrl;

        if (serviceName == null) {
            log.debug("Service name null, authenticating with unamgiguous oauthService");
            OAuthService oauthService = getUnambiguousService();
            authorizationUrl = oauthService.getAuthorizationUrl();
        } else {
            log.debug("authenticating service \"" + serviceName + "\"");
            authorizationUrl = multiServicesManager.initNewSession(serviceName);
        }
View Full Code Here

Examples of org.jboss.seam.social.oauth.OAuthService

    }

    @Override
    public void connect() {

        OAuthService currentService;
        OAuthSession currentSession;

        if (serviceName != null) {
            MultiServicesManager manager = multiServicesManager;
            manager.connectCurrentService();

            currentService = manager.getCurrentService();
            currentSession = manager.getCurrentSession();
        } else {
            currentService = getUnambiguousService();
            currentSession = currentService.getSession();

            currentService.initAccessToken();
        }

        OAuthUser user = new OAuthUser(currentService.getType(), currentSession.getUserProfile());

        if (isIdentityManaged()) {
            // By default we set the status to FAILURE, if we manage to get to the end
            // of this method we get rewarded with a SUCCESS
            setStatus(AuthenticationStatus.FAILURE);
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        String state = RandomStringUtils.randomAlphabetic(10);
        String key = RandomStringUtils.randomAlphabetic(10);
        String secret = RandomStringUtils.randomAlphabetic(10);
        LinkedInApi20 api = new LinkedInApi20(state);

        OAuthService service = new ServiceBuilder().provider(api).apiKey(key).apiSecret(secret)
                .callback("http://localhost:4502/linkedin").build();

        String expected = "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=" + key
                + "&state=" + state + "&redirect_uri=" + OAuthEncoder.encode("http://localhost:4502/linkedin");

        assertEquals(expected, service.getAuthorizationUrl(null));
    }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

        String state = RandomStringUtils.randomAlphabetic(10);
        String key = RandomStringUtils.randomAlphabetic(10);
        String secret = RandomStringUtils.randomAlphabetic(10);
        LinkedInApi20 api = new LinkedInApi20(state);

        OAuthService service = new ServiceBuilder().provider(api).apiKey(key).apiSecret(secret)
                .callback("http://localhost:4502/linkedin").scope("r_basicprofile,r_emailaddress")
                .build();

        String expected = "https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=" + key
                + "&state=" + state + "&redirect_uri=" + OAuthEncoder.encode("http://localhost:4502/linkedin")
                + "&scope=" + "r_basicprofile%2Cr_emailaddress";

        assertEquals(expected, service.getAuthorizationUrl(null));
    }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

            httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
            return;
        }

        Verifier verifier = new Verifier(inboundVerifier);
        OAuthService service = getOAuthService(httpRequest, false);

        // TODO: Store this token if authorization succeeds
        Token accessToken = service.getAccessToken(storedToken, verifier);

        OAuthRequest authRequest = new OAuthRequest(Verb.GET, "https://api.twitter.com/1.1/account/verify_credentials.json");
        service.signRequest(accessToken, authRequest);
        Response authResponse = authRequest.send();

        if (!authResponse.isSuccessful()) {
            LOGGER.warn("OAuth handshake completed, but Twitter credential verification failed: " + authResponse.getMessage());
            httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN);
View Full Code Here

Examples of org.scribe.oauth.OAuthService

            login(httpRequest, httpResponse, chain);
        }
    }

    private void login(HttpServletRequest httpRequest, HttpServletResponse httpResponse, HandlerChain chain) throws IOException {
        OAuthService service = getOAuthService(httpRequest, true);
        Token requestToken = service.getRequestToken();
        httpRequest.getSession().setAttribute(OAUTH_REQUEST_TOKEN, requestToken);
        String authUrl = service.getAuthorizationUrl(requestToken);
        httpResponse.sendRedirect(authUrl);
    }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

      @RequestParam String target, WebRequest request) {
    Site site = (Site) request.getAttribute(AttributeKeys.SITE_KEY, WebRequest.SCOPE_REQUEST);
    String callback = site.getHomeURL()+ "/oauth/callback/" + target;
    String beanId = target + ApiService.class.getSimpleName();
    ApiService apiService = appContext.getBean(beanId, ApiService.class);
    OAuthService oAuthService = apiService.getOAuthService(callback);
    Token requestToken = oAuthService.getRequestToken();
    oAuthServices.put(requestToken, oAuthService);
    requestTokens.put(requestToken.getToken(), requestToken);
    String authUrl = oAuthService.getAuthorizationUrl(requestToken);
    Map<String, Object> model = CollectionUtil.newHashMap();
    model.put("authUrl", authUrl);
    return model;
  }
View Full Code Here

Examples of org.scribe.oauth.OAuthService

  public ResponseEntity<String> callback(@PathVariable String target,
      @RequestParam String oauth_token, @RequestParam String oauth_verifier, HttpSession session) {
    Long userId = (Long) session.getAttribute(AttributeKeys.USER_ID_KEY);
    Token requestToken = requestTokens.get(oauth_token);
    Verifier verifier = new Verifier(oauth_verifier);
    OAuthService oAuthService = oAuthServices.get(requestToken);
    Token accessToken = oAuthService.getAccessToken(requestToken, verifier);
    Authorization authorization = new Authorization(
                    target,
                    accessToken.getToken(),
                    accessToken.getSecret(),
                    userId);
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.