Package org.apache.shiro.subject

Examples of org.apache.shiro.subject.SimplePrincipalCollection


   
    @Test
    public void testRealmWithRolePermissionResolver()
    {  
        Principal principal = new UsernamePrincipal("rolePermResolver");
        PrincipalCollection pCollection = new SimplePrincipalCollection(principal, "testRealmWithRolePermissionResolver");
       
        AuthorizingRealm realm = new AllowAllRealm();
        realm.setRolePermissionResolver( new RolePermissionResolver()
        {
            public Collection<Permission> resolvePermissionsInRole( String roleString )
View Full Code Here


   * 更新用户授权信息缓存.
   */
  public void clearCachedAuthorizationInfo(String loginName) {
    ShiroUser shiroUser = new ShiroUser(loginName);
   
    SimplePrincipalCollection principals = new SimplePrincipalCollection(shiroUser, getName());
    clearCachedAuthorizationInfo(principals);
  }
View Full Code Here

     *
     * @return a new principal collection using the subject as the principal
     */
    @Override
    public PrincipalCollection getPrincipals() {
        return new SimplePrincipalCollection(this.subject.getPrincipals(), this.realmName);
    }
View Full Code Here

        DefaultSecurityManager sm = new DefaultSecurityManager();
        sm.setAuthenticator(new Authenticator() {
            @Override
            public AuthenticationInfo authenticate(AuthenticationToken authenticationToken)
                throws AuthenticationException {
                return new SimpleAuthenticationInfo(new SimplePrincipalCollection(authenticationToken.getPrincipal(),
                    "openengsb"), authenticationToken.getCredentials());
            }
        });
        SecurityUtils.setSecurityManager(sm);
        ThreadContext.bind(sm);
View Full Code Here

    @Test
    public void testIsAnonymousAccount() {
        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("anonymous", "iniRealm");
            }
        };
        assertTrue(policy.isAnonymousAccount(subject));
    }
View Full Code Here

        policy.setAnonymousAccessAllowed(true);

        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("anonymous", "iniRealm");
            }
        };
        SubjectConnectionReference sc = new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                new DefaultEnvironment(), subject);
View Full Code Here

        policy.setAnonymousAccessAllowed(true);

        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("system", "iniRealm");
            }
        };
        SubjectConnectionReference sc = new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                new DefaultEnvironment(), subject);
View Full Code Here

    public void testIsAuthenticationRequiredWhenSystemConnectionAndSystemSubject() {

        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("system", "iniRealm");
            }
        };
        SubjectConnectionReference sc = new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                new DefaultEnvironment(), subject);
View Full Code Here

        policy.setVmConnectionAuthenticationRequired(true);

        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("system", "iniRealm");
            }
        };
        SubjectConnectionReference sc = new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                new DefaultEnvironment(), subject);
View Full Code Here

    public void testIsAuthenticationRequiredWhenSystemConnectionDoesNotRequireAuthenticationAndNotSystemAccount() {

        Subject subject = new SubjectAdapter() {
            @Override
            public PrincipalCollection getPrincipals() {
                return new SimplePrincipalCollection("foo", "iniRealm");
            }
        };
        SubjectConnectionReference sc = new SubjectConnectionReference(new ConnectionContext(), new ConnectionInfo(),
                new DefaultEnvironment(), subject);
View Full Code Here

TOP

Related Classes of org.apache.shiro.subject.SimplePrincipalCollection

Copyright © 2018 www.massapicom. 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.