Examples of SocialProvider


Examples of org.encuestame.utils.social.SocialProvider

            HttpServletRequest httpRequest,
            WebRequest request) throws Exception {
        log.error("ERROR error_code" + error_code);
        log.error("ERROR error_msg" + error_msg);
        log.error("ERROR socialProvider" + socialProvider);
        final SocialProvider soProvider = SocialProvider.getProvider(socialProvider);
        return this.redirect+"#provider=" + soProvider.toString().toLowerCase() + "&refresh=true&successful=false";
    }
View Full Code Here

Examples of org.encuestame.utils.social.SocialProvider

        @PathVariable String provider,
        WebRequest request,
        @RequestParam(required = false) String scope,
        HttpServletRequest httpRequest){
        final StringBuilder url = new StringBuilder();
        final SocialProvider providerEnum = SocialProvider.getProvider(provider);
        log.debug("PROVIDER "+providerEnum);
        if (providerEnum == null) {
            url.append("404");
        } else {
            if (SocialProvider.GOOGLE_BUZZ.equals(providerEnum)) {
               OAuth2Parameters auth2Parameters = new OAuth2Parameters(
                        EnMePlaceHolderConfigurer.getProperty("google.register.client.id"),
                        EnMePlaceHolderConfigurer.getProperty("google.register.client.secret"),
                        EnMePlaceHolderConfigurer.getProperty("google.accesToken"),
                        EnMePlaceHolderConfigurer.getProperty("google.authorizeURl"),
                        SocialProvider.GOOGLE_BUZZ,
                        EnMePlaceHolderConfigurer.getProperty("google.register.client.id"));
                auth2RequestProvider  =  new OAuth2RequestFlow(auth2Parameters);
                auth2RequestProvider.DEFAULT_CALLBACK_PATH = POST_REGISTER_REDIRECT;
                url.append(auth2RequestProvider.buildOAuth2AuthorizeUrl(
                        EnMePlaceHolderConfigurer.getProperty("google.buzz.scope"), httpRequest, false));
                url.append("&state=");
                url.append(providerEnum.toString());
            } else if (SocialProvider.FACEBOOK.equals(providerEnum)) {
                OAuth2Parameters auth2Parameters = new OAuth2Parameters(
                        EnMePlaceHolderConfigurer.getProperty("facebook.api.key"),
                        EnMePlaceHolderConfigurer.getProperty("facebook.api.secret"),
                        EnMePlaceHolderConfigurer.getProperty("facebook.oauth.accesToken"),
View Full Code Here

Examples of org.encuestame.utils.social.SocialProvider

               if (log.isDebugEnabled()) {
                   log.debug(accessGrant.getAccessToken());
                   log.debug(accessGrant.getRefreshToken());
               }
            String friendsUrl = "redirect:/user/signin/friends";
            final SocialProvider providerBack;
            if ("google".equals(provider) && state != null) {
                providerBack = SocialProvider.getProvider(state);
            } else {
                providerBack = SocialProvider.getProvider(provider);
            }
            if (providerBack == null) {
                throw new EnMeOAuthSecurityException("provider ["+provider+"] not valid");
            }
            if (providerBack.equals(SocialProvider.GOOGLE_BUZZ)) {
                friendsUrl = getConnectOperations().connectSignInAccount(
                        new GoogleBuzzSignInSocialService(accessGrant,
                                getConnectOperations()));
            } else if (SocialProvider.getProvider(provider).equals(
                    SocialProvider.FACEBOOK)) {
View Full Code Here

Examples of org.encuestame.utils.social.SocialProvider

    /**
     * Test social provider.
     */
    @Test
    public void testSocialProvider(){
        final SocialProvider twitterProvider = SocialProvider.getProvider("TWITTER");
        assertEquals("Should be equals", "TWITTER", twitterProvider.toString());

        final SocialProvider facebookProvider = SocialProvider.getProvider("FACEBOOK");
        assertEquals("Should be equals", "FACEBOOK", facebookProvider.toString());

        final SocialProvider identicaProvider = SocialProvider.getProvider("IDENTICA");
        assertEquals("Should be equals", "IDENTICA", identicaProvider.toString());

        final SocialProvider linkedinProvider = SocialProvider.getProvider("LINKEDIN");
        assertEquals("Should be equals", "LINKEDIN", linkedinProvider.toString());

        final SocialProvider mySpaceProvider = SocialProvider.getProvider("YAHOO");
        assertEquals("Should be equals", "YAHOO", mySpaceProvider.toString());

        final SocialProvider googleBuzzProvider = SocialProvider.getProvider("GOOGLE_BUZZ");
        assertEquals("Should be equals", "GOOGLEBUZZ", googleBuzzProvider.toString());

        final SocialProvider yahooProvider = SocialProvider.getProvider("MYSPACE");
        assertEquals("Should be equals", "MYSPACE", yahooProvider.toString());
    }
View Full Code Here

Examples of org.encuestame.utils.social.SocialProvider

     * @return
     */
    public static final List<SocialProvider> convertSocialProviderStringToProvider(
            final List<String> socialProviders) {
        final List<SocialProvider> socialNetworksProviders = new ArrayList<SocialProvider>();
        SocialProvider socialNetworkProv;
        for (String provider : socialProviders) {
            socialNetworkProv = SocialProvider.getProvider(provider);
            if (socialNetworkProv != null) {
                socialNetworksProviders.add(socialNetworkProv);
            }
View Full Code Here

Examples of org.keycloak.social.SocialProvider

        } catch (Throwable t) {
            logger.error("Invalid social callback", t);
            return Flows.forms(session, null, null, uriInfo).setError("Unexpected callback").createErrorPage();
        }
        String providerId = clientSession.getNote("social_provider");
        SocialProvider provider = SocialLoader.load(providerId);

        String authMethod = "social@" + provider.getId();

        RealmModel realm = clientSession.getRealm();

        EventBuilder event = new EventsManager(realm, session, clientConnection).createEventBuilder()
                .event(EventType.LOGIN)
                .client(clientSession.getClient())
                .detail(Details.REDIRECT_URI, clientSession.getRedirectUri())
                .detail(Details.AUTH_METHOD, authMethod);

        if (!realm.isEnabled()) {
            event.error(Errors.REALM_DISABLED);
            return Flows.forwardToSecurityFailurePage(session, realm, uriInfo, "Realm not enabled.");
        }

        String key = realm.getSocialConfig().get(provider.getId() + ".key");
        String secret = realm.getSocialConfig().get(provider.getId() + ".secret");
        String callbackUri = Urls.socialCallback(uriInfo.getBaseUri()).toString();
        SocialProviderConfig config = new SocialProviderConfig(key, secret, callbackUri);

        Map<String, String[]> queryParams = getQueryParams();

        AuthCallback callback = new AuthCallback(queryParams);

        SocialUser socialUser;
        try {
            socialUser = provider.processCallback(clientSession, config, callback);
        } catch (SocialAccessDeniedException e) {
            event.error(Errors.REJECTED_BY_USER);
            clientSession.setAction(ClientSessionModel.Action.AUTHENTICATE);
            return  Flows.forms(session, realm, clientSession.getClient(), uriInfo).setClientSessionCode(clientCode.getCode()).setWarning("Access denied").createLogin();
        } catch (SocialProviderException e) {
            logger.error("Failed to process social callback", e);
            return Flows.forwardToSecurityFailurePage(session, realm, uriInfo, "Failed to process social callback");
        }

        event.detail(Details.USERNAME, socialUser.getId() + "@" + provider.getId());

        try {
            SocialLinkModel socialLink = new SocialLinkModel(provider.getId(), socialUser.getId(), socialUser.getUsername());
            UserModel user = session.users().getUserBySocialLink(socialLink, realm);

            // Check if user is already authenticated (this means linking social into existing user account)
            if (clientSession.getUserSession() != null) {

                UserModel authenticatedUser = clientSession.getUserSession().getUser();

                event.event(EventType.SOCIAL_LINK).user(authenticatedUser.getId());

                if (user != null) {
                    event.error(Errors.SOCIAL_ID_IN_USE);
                    return Flows.forwardToSecurityFailurePage(session, realm, uriInfo, "This social account is already linked to other user");
                }

                if (!authenticatedUser.isEnabled()) {
                    event.error(Errors.USER_DISABLED);
                    return Flows.forwardToSecurityFailurePage(session, realm, uriInfo, "User is disabled");
                }

                if (!authenticatedUser.hasRole(realm.getApplicationByName(Constants.ACCOUNT_MANAGEMENT_APP).getRole(AccountRoles.MANAGE_ACCOUNT))) {
                    event.error(Errors.NOT_ALLOWED);
                    return Flows.forwardToSecurityFailurePage(session, realm, uriInfo, "Insufficient permissions to link social account");
                }

                session.users().addSocialLink(realm, authenticatedUser, socialLink);
                logger.debugv("Social provider {0} linked with user {1}", provider.getId(), authenticatedUser.getUsername());

                event.success();
                return Response.status(302).location(UriBuilder.fromUri(clientSession.getRedirectUri()).build()).build();
            }

            if (user == null) {
                user = session.users().addUser(realm, KeycloakModelUtils.generateId());
                user.setEnabled(true);
                user.setFirstName(socialUser.getFirstName());
                user.setLastName(socialUser.getLastName());
                user.setEmail(socialUser.getEmail());

                if (realm.isUpdateProfileOnInitialSocialLogin()) {
                    user.addRequiredAction(UserModel.RequiredAction.UPDATE_PROFILE);
                }

                session.users().addSocialLink(realm, user, socialLink);

                event.clone().user(user).event(EventType.REGISTER)
                        .detail(Details.REGISTER_METHOD, "social@" + provider.getId())
                        .detail(Details.EMAIL, socialUser.getEmail())
                        .removeDetail("auth_method")
                        .success();
            }
View Full Code Here

Examples of org.keycloak.social.SocialProvider

        EventBuilder event = new EventsManager(realm, session, clientConnection).createEventBuilder()
                .event(EventType.LOGIN)
                .detail(Details.AUTH_METHOD, "social@" + providerId);

        SocialProvider provider = SocialLoader.load(providerId);
        if (provider == null) {
            event.error(Errors.SOCIAL_PROVIDER_NOT_FOUND);
            return Flows.forms(session, realm, null, uriInfo).setError("Social provider not found").createErrorPage();
        }
View Full Code Here

Examples of org.keycloak.social.SocialProvider

        if (accountSocialAction == null) {
            setReferrerOnPage();
            return account.setError(Messages.INVALID_SOCIAL_ACTION).createResponse(AccountPages.SOCIAL);
        }

        SocialProvider provider = SocialLoader.load(providerId);
        if (provider == null) {
            setReferrerOnPage();
            return account.setError(Messages.SOCIAL_PROVIDER_NOT_FOUND).createResponse(AccountPages.SOCIAL);
        }
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.