List of usage examples for org.apache.shiro.subject.support DelegatingSubject getPrincipals
public PrincipalCollection getPrincipals()
From source file:ddf.security.impl.SubjectImplTest.java
License:Open Source License
/** * Checks to make sure that the values are being passed through our implementation to the backed * implementation correctly.//from ww w.j a v a2s .c o m */ @Test public void testSixParamConstructor() { DelegatingSubject testSubject = new SubjectImpl(createTestCollection(), false, TEST_HOST, TEST_SESSION, false, TEST_MANAGER); assertEquals(createTestCollection(), testSubject.getPrincipals()); assertFalse(testSubject.isAuthenticated()); assertEquals(TEST_HOST, testSubject.getHost()); assertEquals(TEST_SESSION.getId(), testSubject.getSession().getId()); assertEquals(TEST_MANAGER, testSubject.getSecurityManager()); }
From source file:ddf.security.impl.SubjectImplTest.java
License:Open Source License
@Test public void testFiveParamConstructor() { DelegatingSubject testSubject = new SubjectImpl(createTestCollection(), false, TEST_HOST, TEST_SESSION, TEST_MANAGER);/* w ww . ja v a 2 s. c om*/ assertEquals(createTestCollection(), testSubject.getPrincipals()); assertFalse(testSubject.isAuthenticated()); assertEquals(TEST_HOST, testSubject.getHost()); assertEquals(TEST_SESSION.getId(), testSubject.getSession().getId()); assertEquals(TEST_MANAGER, testSubject.getSecurityManager()); }
From source file:ddf.security.impl.SubjectImplTest.java
License:Open Source License
@Test public void testFourParamConstructor() { DelegatingSubject testSubject = new SubjectImpl(createTestCollection(), false, TEST_SESSION, TEST_MANAGER); assertEquals(createTestCollection(), testSubject.getPrincipals()); assertFalse(testSubject.isAuthenticated()); assertEquals(TEST_SESSION.getId(), testSubject.getSession().getId()); assertEquals(TEST_MANAGER, testSubject.getSecurityManager()); }
From source file:org.mule.module.shiro.AuthorizationFilter.java
License:Open Source License
@Override public void doFilter(MuleEvent event) throws SecurityException, UnknownAuthenticationTypeException, CryptoFailureException, SecurityProviderNotFoundException, EncryptionStrategyNotFoundException, InitialisationException { Authentication auth = event.getSession().getSecurityContext().getAuthentication(); if (!(auth instanceof ShiroAuthenticationResult)) { throw new UnknownAuthenticationTypeException(auth); }//from ww w. ja va 2 s .co m ShiroAuthenticationResult shiroAuth = (ShiroAuthenticationResult) auth; try { Collection<Permission> permissions = getPermissions(event); if (permissions != null) { shiroAuth.getSubject().checkPermissions(permissions); } Collection<String> roles = getRoles(event); if (roles != null) { // work around SHIRO-234 and SHIRO-235 DelegatingSubject subj = ((DelegatingSubject) shiroAuth.getSubject()); subj.getSecurityManager().checkRoles(subj.getPrincipals(), roles.toArray(new String[0])); } } catch (UnauthorizedException e) { throw new NotPermittedException(event, event.getSession().getSecurityContext(), this); } }
From source file:org.obiba.opal.core.security.SessionDetachedSubject.java
License:Open Source License
SessionDetachedSubject(DelegatingSubject source) { super(source.getPrincipals(), source.isAuthenticated(), null, null, source.getSecurityManager()); }