当前位置: 首页>>代码示例>>Java>>正文


Java CommonHelper类代码示例

本文整理汇总了Java中org.pac4j.core.util.CommonHelper的典型用法代码示例。如果您正苦于以下问题:Java CommonHelper类的具体用法?Java CommonHelper怎么用?Java CommonHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommonHelper类属于org.pac4j.core.util包,在下文中一共展示了CommonHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalInit

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
    CommonHelper.assertNotBlank("accessId", accessId);
    CommonHelper.assertNotBlank("secretKey", secretKey);
    CommonHelper.assertNotBlank("applicationId", applicationId);

    try {
        final Client client = new Client(new DefaultApiKey(accessId, secretKey));
        this.application = client.getDataStore().getResource(
                String.format("/applications/%s", applicationId), Application.class);
    } catch (final Exception e) {
        throw new BadCredentialsException("An exception is caught trying to access Stormpath cloud. " +
                "Please verify that your provided Stormpath <accessId>, " +
                "<secretKey>, and <applicationId> are correct. Original Stormpath error: " + e.getMessage());
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:StormpathAuthenticator.java

示例2: updateCallbackUrlOfIndirectClient

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
/**
 * Sets a client's Callback URL, if not already set. If requested, the "client_name" parameter will also be a part of the URL.
 * 
 * @param indirectClient A client.
 */
protected void updateCallbackUrlOfIndirectClient(final IndirectClient indirectClient) {
    String indirectClientCallbackUrl = indirectClient.getCallbackUrl();
    // no callback url defined for the client but a group callback one -> set it with the group callback url
    if (CommonHelper.isNotBlank(this.callbackUrl) && indirectClientCallbackUrl == null) {
        indirectClient.setCallbackUrl(this.callbackUrl);
        indirectClientCallbackUrl = this.callbackUrl;
    }
    // if the "client_name" parameter is not already part of the client callback url, add it unless the client has indicated to not include it.
    if (indirectClient.isIncludeClientNameInCallbackUrl() && indirectClientCallbackUrl != null && !indirectClientCallbackUrl.contains(this.clientNameParameter + "=")) {
        indirectClient.setCallbackUrl(CommonHelper.addParameter(indirectClientCallbackUrl, this.clientNameParameter, indirectClient.getName()));
    }
    final AjaxRequestResolver clientAjaxRequestResolver = indirectClient.getAjaxRequestResolver();
    if (ajaxRequestResolver != null && (clientAjaxRequestResolver == null || clientAjaxRequestResolver instanceof DefaultAjaxRequestResolver)) {
        indirectClient.setAjaxRequestResolver(ajaxRequestResolver);
    }
    final CallbackUrlResolver clientCallbackUrlResolver = indirectClient.getCallbackUrlResolver();
    if (callbackUrlResolver != null && (clientCallbackUrlResolver == null || clientCallbackUrlResolver instanceof DefaultCallbackUrlResolver)) {
        indirectClient.setCallbackUrlResolver(this.callbackUrlResolver);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:26,代码来源:Clients.java

示例3: verifyProfile

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void verifyProfile(CommonProfile userProfile) {
    final Google2Profile profile = (Google2Profile) userProfile;
    assertEquals("113675986756217860428", profile.getId());
    assertEquals(Google2Profile.class.getName() + CommonProfile.SEPARATOR + "113675986756217860428",
            profile.getTypedId());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), Google2Profile.class));
    assertTrue(CommonHelper.isNotBlank(profile.getAccessToken()));
    assertCommonProfile(userProfile, "[email protected]", "Jérôme", "ScribeUP", "Jérôme ScribeUP", null,
            Gender.MALE, Locale.ENGLISH,
            "https://lh4.googleusercontent.com/-fFUNeYqT6bk/AAAAAAAAAAI/AAAAAAAAAAA/5gBL6csVWio/photo.jpg",
            "https://plus.google.com/113675986756217860428", null);
    assertNull(profile.getBirthday());
    assertTrue(profile.getEmails() != null && profile.getEmails().size() == 1);
    assertEquals(9, profile.getAttributes().size());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:RunGoogle2Client.java

示例4: internalInit

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
/**
     * Initialize all clients by computing callback urls if necessary.
     */
    @Override
    protected void internalInit() {
        CommonHelper.assertNotNull("clients", getClients());
        final HashSet<String> names = new HashSet<>();
        for (final T client : getClients()) {
            final String name = client.getName();
            final String lowerName = name.toLowerCase();
            if (names.contains(lowerName)) {
                throw new TechnicalException("Duplicate name in clients: " + name);
            }
            names.add(lowerName);

            // Instead of using brittle client type checking, make it the responsibility of the client to know how
            // to configure itself from the Clients object
            client.configureFromClientsObject(this);
//            if (client instanceof IndirectClient) {
//                updateCallbackUrlOfIndirectClient((IndirectClient) client);
//            }
//            final BaseClient baseClient = (BaseClient) client;
//            if (!authorizationGenerators.isEmpty()) {
//                baseClient.addAuthorizationGenerators(this.authorizationGenerators);
//            }
        }
    }
 
开发者ID:millross,项目名称:pac4j-async,代码行数:28,代码来源:Clients.java

示例5: matches

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> matches(AsyncWebContext context, String matcherNames, Map<String, AsyncMatcher> matchersMap) {

    // if we have a matcher name (which may be a list of matchers names)
    if (CommonHelper.isNotBlank(matcherNames)) {

        // we must have matchers
        CommonHelper.assertNotNull("matchersMap", matchersMap);
        final String[] names = matcherNames.split(Pac4jConstants.ELEMENT_SEPRATOR);

        final List<AsyncMatcher> matchers = Arrays.stream(names)
                .map(n -> matchersMap.entrySet().stream()
                        .filter(e -> CommonHelper.areEqualsIgnoreCaseAndTrim(e.getKey(), n))
                        .peek(e -> CommonHelper.assertNotNull("matchersMap['" + n + "']", e))
                        .findFirst().map(e -> e.getValue()).orElse(null))
                .collect(Collectors.toList());

        return shortCircuitedFuture(matchers.stream()
                    .map(m -> () -> m.matches(context)), false);
    }

    return CompletableFuture.completedFuture(true);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:24,代码来源:DefaultAsyncMatchingChecker.java

示例6: verifyProfile

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void verifyProfile(CommonProfile userProfile) {
    final OkProfile profile = (OkProfile) userProfile;
    assertEquals(TEST_PROFILE_ID, profile.getId());
    assertEquals(OkProfile.class.getName() + CommonProfile.SEPARATOR + TEST_PROFILE_ID,
            profile.getTypedId());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), OkProfile.class));
    assertTrue(CommonHelper.isNotBlank(profile.getAccessToken()));
    assertCommonProfile(
            userProfile,
            null,
            TEST_FIRST_NAME,
            TEST_LAST_NAME,
            TEST_FIRST_NAME + " " + TEST_LAST_NAME,
            TEST_PROFILE_ID,
            Gender.MALE,
            new Locale(TEST_LOCALE),
            TEST_PROFILE_PICTURE_URL,
            OkProfile.BASE_PROFILE_URL + TEST_PROFILE_ID,
            TEST_LOCATION);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:RunOkClient.java

示例7: updateCallback

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
private void updateCallback(Clients<AsyncClient<C, U>, AsyncAuthorizationGenerator<U>> toConfigureFrom) {
    String callbackUrl = getCallbackUrl();
    Clients clients = null;
    if (toConfigureFrom instanceof Clients) {
        clients = toConfigureFrom;
    }
    // no callback url defined for the client but a group callback one -> set it with the group callback url
    if (CommonHelper.isNotBlank(clients.getCallbackUrl()) && callbackUrl == null) {
        setCallbackUrl(clients.getCallbackUrl());
        callbackUrl = this.callbackUrl;
    }

    // if the "client_name" parameter is not already part of the client callback url, add it unless the client has indicated to not include it.
    if (isIncludeClientNameInCallbackUrl() && callbackUrl != null && !callbackUrl.contains(clients.getClientNameParameter() + "=")) {
        setCallbackUrl(CommonHelper.addParameter(callbackUrl, clients.getClientNameParameter(), getName()));
    }
    final AjaxRequestResolver clientAjaxRequestResolver = getAjaxRequestResolver();
    if (ajaxRequestResolver != null && (clientAjaxRequestResolver == null || clientAjaxRequestResolver instanceof DefaultAjaxRequestResolver)) {
        setAjaxRequestResolver(ajaxRequestResolver);
    }
    final UrlResolver clientUrlResolver = getUrlResolver();
    if (urlResolver != null && (clientUrlResolver == null || clientUrlResolver instanceof DefaultUrlResolver)) {
        setUrlResolver(this.urlResolver);
    }
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:26,代码来源:AsyncIndirectClient.java

示例8: internalInit

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void internalInit(AsyncWebContext context) {

    CommonHelper.assertNotBlank("callbackUrl", this.callbackUrl,
            "set it up either on this client or the global Config");
    CommonHelper.assertNotNull("urlResolver", this.urlResolver);
    CommonHelper.assertNotNull("ajaxRequestResolver", this.ajaxRequestResolver);

    clientInit(context);

    // ensures components have been properly initialized
    CommonHelper.assertNotNull("redirectActionBuilder", this.redirectActionBuilder);
    CommonHelper.assertNotNull("credentialsExtractor", getCredentialsExtractor());
    CommonHelper.assertNotNull("authenticator", getAuthenticator());
    CommonHelper.assertNotNull("profileCreator", getProfileCreator());
    CommonHelper.assertNotNull("logoutActionBuilder", this.logoutActionBuilder);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:19,代码来源:AsyncIndirectClient.java

示例9: clientInit

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void clientInit(final AsyncWebContext context) {
    CommonHelper.assertNotBlank("fields", this.fields);
    configuration.setApi(FacebookApi.instance());
    configuration.setProfileDefinition(new FacebookProfileDefinition());
    configuration.setScope(scope);
    configuration.setHasBeenCancelledFactory(ctx -> {
        final String error = ctx.getRequestParameter(OAuthCredentialsException.ERROR);
        final String errorReason = ctx.getRequestParameter(OAuthCredentialsException.ERROR_REASON);
        // user has denied permissions
        if ("access_denied".equals(error) && "user_denied".equals(errorReason)) {
            return true;
        } else {
            return false;
        }
    });
    configuration.setWithState(true);
    setConfiguration(configuration);
    defaultProfileCreator(new AsyncFacebookProfileCreator(configuration));

    super.clientInit(context);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:23,代码来源:AsyncFacebookClient.java

示例10: tryCreateFacebookClient

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
private void tryCreateFacebookClient(final List<Client> clients) {
    final String id = getProperty(FACEBOOK_ID);
    final String secret = getProperty(FACEBOOK_SECRET);
    final String scope = getProperty(FACEBOOK_SCOPE);
    final String fields = getProperty(FACEBOOK_FIELDS);
    if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
        final FacebookClient facebookClient = new FacebookClient(id, secret);
        if (CommonHelper.isNotBlank(scope)) {
            facebookClient.setScope(scope);
        }
        if (CommonHelper.isNotBlank(fields)) {
            facebookClient.setFields(fields);
        }
        clients.add(facebookClient);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:PropertiesConfigFactory.java

示例11: internalInit

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
    if (CommonHelper.isBlank(this.loginUrl) && CommonHelper.isBlank(this.prefixUrl)) {
        throw new TechnicalException("loginUrl and prefixUrl cannot be both blank");
    }

    initializeClientConfiguration(context);

    initializeLogoutHandler(context);

    if (this.protocol == CasProtocol.CAS10) {
        initializeCas10Protocol();
    } else if (this.protocol == CasProtocol.CAS20) {
        initializeCas20Protocol(context);
    } else if (this.protocol == CasProtocol.CAS20_PROXY) {
        initializeCas20ProxyProtocol(context);
    } else if (this.protocol == CasProtocol.CAS30) {
        initializeCas30Protocol(context);
    } else if (this.protocol == CasProtocol.CAS30_PROXY) {
        initializeCas30ProxyProtocol(context);
    } else if (this.protocol == CasProtocol.SAML) {
        initializeSAMLProtocol();
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:25,代码来源:CasConfiguration.java

示例12: retrieveCredentials

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected C retrieveCredentials(final WebContext context) throws HttpAction {
    CommonHelper.assertNotNull("credentialsExtractor", this.credentialsExtractor);
    CommonHelper.assertNotNull("authenticator", this.authenticator);

    try {
        final C credentials = this.credentialsExtractor.extract(context);
        if (credentials == null) {
            return null;
        }
        this.authenticator.validate(credentials, context);
        return credentials;
    } catch (CredentialsException e) {
        logger.info("Failed to retrieve or validate credentials: {}", e.getMessage());
        logger.debug("Failed to retrieve or validate credentials", e);

        return null;
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:IndirectClientV2.java

示例13: redirectToApproveView

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
/**
 * Redirect to approve view model and view.
 *
 * @param ctx the ctx
 * @param svc the svc
 * @return the model and view
 */
protected ModelAndView redirectToApproveView(final J2EContext ctx, final OAuthRegisteredService svc) {
    String callbackUrl = ctx.getFullRequestURL();
    callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.BYPASS_APPROVAL_PROMPT, "true");
    LOGGER.debug("callbackUrl: [{}]", callbackUrl);

    final Map<String, Object> model = new HashMap<>();
    model.put("service", svc);
    model.put("callbackUrl", callbackUrl);
    model.put("serviceName", svc.getName());
    model.put("deniedApprovalUrl", svc.getAccessStrategy().getUnauthorizedRedirectUrl());

    prepareApprovalViewModel(model, ctx, svc);
    return getApprovalModelAndView(model);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:OAuth20ConsentApprovalViewResolver.java

示例14: retrieveUserProfileFromToken

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
protected YahooProfile retrieveUserProfileFromToken(final OAuth1Token accessToken) throws HttpAction {
    // get the guid: https://developer.yahoo.com/social/rest_api_guide/introspective-guid-resource.html
    String body = sendRequestForData(accessToken, getProfileUrl(accessToken));
    final String guid = CommonHelper.substringBetween(body, "<value>", "</value>");
    logger.debug("guid : {}", guid);
    if (CommonHelper.isBlank(guid)) {
        final String message = "Cannot find guid from body : " + body;
        throw new HttpCommunicationException(message);
    }
    body = sendRequestForData(accessToken, "https://social.yahooapis.com/v1/user/" + guid + "/profile?format=json");
    final YahooProfile profile = extractUserProfile(body);
    addAccessTokenToProfile(profile, accessToken);
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:16,代码来源:YahooClient.java

示例15: toString

import org.pac4j.core.util.CommonHelper; //导入依赖的package包/类
@Override
public String toString() {
    return CommonHelper.toString(getClass(),
            "callbackUrl", callbackUrl,
            "name", getName(),
            "loginUrl", loginUrl,
            "redirectActionBuilder", getRedirectActionBuilder(),
            "extractor", getCredentialsExtractor(),
            "authenticator", getAuthenticator(),
            "profileCreator", getProfileCreator());
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:12,代码来源:IdCardClient.java


注:本文中的org.pac4j.core.util.CommonHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。