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


Java SubjectContext.resolvePrincipals方法代码示例

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


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

示例1: resolvePrincipals

import org.apache.shiro.subject.SubjectContext; //导入方法依赖的package包/类
/**
 * Attempts to resolve an identity (a {@link PrincipalCollection}) for the context using heuristics.  This
 * implementation functions as follows:
 * <ol>
 * <li>Check the context to see if it can already {@link SubjectContext#resolvePrincipals resolve an identity}.  If
 * so, this method does nothing and returns the method argument unaltered.</li>
 * <li>Check for a RememberMe identity by calling {@link #getRememberedIdentity}.  If that method returns a
 * non-null value, place the remembered {@link PrincipalCollection} in the context.</li>
 * </ol>
 *
 * @param context the subject context data that may provide (directly or indirectly through one of its values) a
 *                {@link PrincipalCollection} identity.
 * @return The Subject context to use to pass to a {@link SubjectFactory} for subject creation.
 * @since 1.0
 */
@SuppressWarnings({"unchecked"})
protected SubjectContext resolvePrincipals(SubjectContext context) {

    PrincipalCollection principals = context.resolvePrincipals();

    if (CollectionUtils.isEmpty(principals)) {
        log.trace("No identity (PrincipalCollection) found in the context.  Looking for a remembered identity.");

        principals = getRememberedIdentity(context);

        if (!CollectionUtils.isEmpty(principals)) {
            log.debug("Found remembered PrincipalCollection.  Adding to the context to be used " +
                    "for subject construction by the SubjectFactory.");

            context.setPrincipals(principals);

            // The following call was removed (commented out) in Shiro 1.2 because it uses the session as an
            // implementation strategy.  Session use for Shiro's own needs should be controlled in a single place
            // to be more manageable for end-users: there are a number of stateless (e.g. REST) applications that
            // use Shiro that need to ensure that sessions are only used when desirable.  If Shiro's internal
            // implementations used Subject sessions (setting attributes) whenever we wanted, it would be much
            // harder for end-users to control when/where that occurs.
            //
            // Because of this, the SubjectDAO was created as the single point of control, and session state logic
            // has been moved to the DefaultSubjectDAO implementation.

            // Removed in Shiro 1.2.  SHIRO-157 is still satisfied by the new DefaultSubjectDAO implementation
            // introduced in 1.2
            // Satisfies SHIRO-157:
            // bindPrincipalsToSession(principals, context);

        } else {
            log.trace("No remembered identity found.  Returning original context.");
        }
    }

    return context;
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:54,代码来源:DefaultSecurityManager.java

示例2: createSubject

import org.apache.shiro.subject.SubjectContext; //导入方法依赖的package包/类
public Subject createSubject(SubjectContext context) {
    SecurityManager securityManager = context.resolveSecurityManager();
    Session session = context.resolveSession();
    boolean sessionCreationEnabled = context.isSessionCreationEnabled();
    PrincipalCollection principals = context.resolvePrincipals();
    boolean authenticated = context.resolveAuthenticated();
    String host = context.resolveHost();

    return new DelegatingSubject(principals, authenticated, host, session, sessionCreationEnabled, securityManager);
}
 
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:11,代码来源:DefaultSubjectFactory.java

示例3: createSubject

import org.apache.shiro.subject.SubjectContext; //导入方法依赖的package包/类
public Subject createSubject(SubjectContext context) {
    org.apache.shiro.mgt.SecurityManager securityManager = context.resolveSecurityManager();
    Session session = context.resolveSession();
    boolean sessionCreationEnabled = context.isSessionCreationEnabled();
    PrincipalCollection principals = context.resolvePrincipals();
    boolean authenticated = context.resolveAuthenticated();
    String host = context.resolveHost();

    return new IOTSubject(principals, authenticated, host, session, sessionCreationEnabled, securityManager);
}
 
开发者ID:caricah,项目名称:iotracah,代码行数:11,代码来源:IOTSubjectFactory.java

示例4: createSubject

import org.apache.shiro.subject.SubjectContext; //导入方法依赖的package包/类
public Subject createSubject(SubjectContext context) {
    org.apache.shiro.mgt.SecurityManager securityManager = context.resolveSecurityManager();
    Session session = context.resolveSession();
    boolean sessionEnabled = context.isSessionCreationEnabled();
    PrincipalCollection principals = context.resolvePrincipals();
    boolean authenticated = context.resolveAuthenticated();
    String host = context.resolveHost();

    return new DelegatingSubject(principals, authenticated, host, session, sessionEnabled, securityManager);
}
 
开发者ID:icode,项目名称:ameba-shiro,代码行数:11,代码来源:DefaultWebSubjectFactory.java


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