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


Java UserProfile.getId方法代码示例

本文整理汇总了Java中org.pac4j.core.profile.UserProfile.getId方法的典型用法代码示例。如果您正苦于以下问题:Java UserProfile.getId方法的具体用法?Java UserProfile.getId怎么用?Java UserProfile.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pac4j.core.profile.UserProfile的用法示例。


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

示例1: createResult

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * Build the handler result.
 *
 * @param credentials the provided credentials
 * @param profile the retrieved user profile
 * @return the built handler result
 * @throws GeneralSecurityException On authentication failure.
 * @throws PreventedException On the indeterminate case when authentication is prevented.
 */
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
        throws GeneralSecurityException, PreventedException {

    if (profile != null) {
        final String id;
        if (typedIdUsed) {
            id = profile.getTypedId();
        } else {
            id = profile.getId();
        }
        if (StringUtils.isNotBlank(id)) {
            credentials.setUserProfile(profile);
            credentials.setTypedIdUsed(typedIdUsed);
            return new DefaultHandlerResult(
                    this,
                    new BasicCredentialMetaData(credentials),
                    this.principalFactory.createPrincipal(id, profile.getAttributes()));
        }

        throw new FailedLoginException("No identifier found for this user profile: " + profile);
    }

    throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:34,代码来源:AbstractPac4jAuthenticationHandler.java

示例2: getAuthenticatedUsername

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * Return the username of the authenticated user (based on pac4j security).
 *
 * @return the authenticated username.
 */
public static String getAuthenticatedUsername() {
    final HttpServletRequest request = getHttpServletRequest();
    final HttpServletResponse response = getHttpServletResponse();
    if (request != null && response != null) {
        final J2EContext context = new J2EContext(request, response);
        final ProfileManager manager = new ProfileManager(context);
        final UserProfile profile = manager.get(true);
        if (profile != null) {
            final String id = profile.getId();
            if (id != null) {
                return id;
            }
        }
    }
    return UNKNOWN_USER;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:WebUtils.java

示例3: createResult

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
    throws GeneralSecurityException, PreventedException {
    final String id;
    if (typedIdUsed) {
        id = profile.getTypedId();
    } else {
        id = profile.getId();
    }
    if (StringUtils.isNotBlank(id)) {
        credentials.setUserProfile(profile);
        return new DefaultHandlerResult(
            this,
            new BasicCredentialMetaData(credentials),
            this.principalFactory.createPrincipal(id, profile.getAttributes()));
    }
    throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:ClientAuthenticationHandler.java

示例4: createResult

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * Build the handler result.
 *
 * @param credentials the provided credentials
 * @param profile     the retrieved user profile
 * @return the built handler result
 * @throws GeneralSecurityException On authentication failure.
 * @throws PreventedException       On the indeterminate case when authentication is prevented.
 */
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
        throws GeneralSecurityException, PreventedException {

    if (profile != null) {
        final String id;
        if (isTypedIdUsed) {
            id = profile.getTypedId();
        } else {
            id = profile.getId();
        }
        if (StringUtils.isNotBlank(id)) {
            credentials.setUserProfile(profile);
            credentials.setTypedIdUsed(isTypedIdUsed);
            return new DefaultHandlerResult(
                    this,
                    new BasicCredentialMetaData(credentials),
                    this.principalFactory.createPrincipal(id, profile.getAttributes()));
        }

        throw new FailedLoginException("No identifier found for this user profile: " + profile);
    }

    throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:34,代码来源:AbstractPac4jAuthenticationHandler.java

示例5: createResult

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
    throws GeneralSecurityException, PreventedException {
    final String id;
    if (typedIdUsed) {
        id = profile.getTypedId();
    } else {
        id = profile.getId();
    }
    if (StringUtils.isNotBlank(id)) {
        credentials.setUserProfile(profile);
        credentials.setTypedIdUsed(typedIdUsed);
        return new DefaultHandlerResult(
            this,
            new BasicCredentialMetaData(credentials),
            this.principalFactory.createPrincipal(id, profile.getAttributes()));
    }
    throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:23,代码来源:ClientAuthenticationHandler.java

示例6: build

import org.pac4j.core.profile.UserProfile; //导入方法依赖的package包/类
/**
 * Create an authentication from a user profile.
 *
 * @param profile           the given user profile
 * @param registeredService the registered service
 * @param context           the context
 * @param service           the service
 * @return the built authentication
 */
public Authentication build(final UserProfile profile,
                            final OAuthRegisteredService registeredService,
                            final J2EContext context,
                            final Service service) {

    final Map<String, Object> profileAttributes = getPrincipalAttributesFromProfile(profile);
    final Principal newPrincipal = this.principalFactory.createPrincipal(profile.getId(), profileAttributes);
    LOGGER.debug("Created final principal [{}] after filtering attributes based on [{}]", newPrincipal, registeredService);

    final String authenticator = profile.getClass().getCanonicalName();
    final CredentialMetaData metadata = new BasicCredentialMetaData(new BasicIdentifiableCredential(profile.getId()));
    final HandlerResult handlerResult = new DefaultHandlerResult(authenticator, metadata, newPrincipal, new ArrayList<>());

    final String state = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.STATE), StringUtils.EMPTY);
    final String nonce = StringUtils.defaultIfBlank(context.getRequestParameter(OAuth20Constants.NONCE), StringUtils.EMPTY);
    LOGGER.debug("OAuth [{}] is [{}], and [{}] is [{}]", OAuth20Constants.STATE, state, OAuth20Constants.NONCE, nonce);

    /**
     * pac4j UserProfile.getPermissions() and getRoles() returns UnmodifiableSet which Jackson Serializer
     * happily serializes to json but is unable to deserialize.
     * We have to wrap it to HashSet to avoid such problem
     */
    final AuthenticationBuilder bldr = DefaultAuthenticationBuilder.newInstance()
            .addAttribute("permissions", new HashSet<>(profile.getPermissions()))
            .addAttribute("roles", new HashSet<>(profile.getRoles()))
            .addAttribute(OAuth20Constants.STATE, state)
            .addAttribute(OAuth20Constants.NONCE, nonce)
            .addCredential(metadata)
            .setPrincipal(newPrincipal)
            .setAuthenticationDate(ZonedDateTime.now())
            .addSuccess(profile.getClass().getCanonicalName(), handlerResult);

    collectionAuthenticationAttributesIfNecessary(profile, bldr);
    return bldr.build();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:45,代码来源:OAuth20CasAuthenticationBuilder.java


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