use of org.apache.shiro.subject.SimplePrincipalCollection in project ddf by codice.
the class SubjectIdentityTest method testUniqueIdentifierNoEmail.
@Test
public void testUniqueIdentifierNoEmail() {
org.apache.shiro.subject.Subject subject;
org.apache.shiro.mgt.SecurityManager secManager = new DefaultSecurityManager();
PrincipalCollection principals = new SimplePrincipalCollection(TEST_NAME, "testrealm");
subject = new Subject.Builder(secManager).principals(principals).session(new SimpleSession()).buildSubject();
assertThat(TEST_NAME, is(subjectIdentity.getUniqueIdentifier(subject)));
}
use of org.apache.shiro.subject.SimplePrincipalCollection in project ddf by codice.
the class SubjectUtilsTest method testGetName.
@Test
public void testGetName() {
org.apache.shiro.subject.Subject subject;
org.apache.shiro.mgt.SecurityManager secManager = new DefaultSecurityManager();
PrincipalCollection principals = new SimplePrincipalCollection(TEST_NAME, "testrealm");
subject = new Subject.Builder(secManager).principals(principals).session(new SimpleSession()).authenticated(true).buildSubject();
assertEquals(TEST_NAME, subjectUtils.getName(subject));
}
use of org.apache.shiro.subject.SimplePrincipalCollection in project ddf by codice.
the class PrincipalHolderTest method testSettingMultipleSecurityTokens.
@Test
public void testSettingMultipleSecurityTokens() {
// given
PrincipalHolder principalHolder = new PrincipalHolder();
PrincipalCollection securityTokenOne = new SimplePrincipalCollection();
PrincipalCollection securityTokenTwo = new SimplePrincipalCollection();
// when
principalHolder.setPrincipals(securityTokenOne);
principalHolder.setPrincipals(securityTokenTwo);
// then
assertThat(principalHolder.getPrincipals(), is(securityTokenTwo));
}
use of org.apache.shiro.subject.SimplePrincipalCollection in project ddf by codice.
the class PrincipalHolderTest method testRetrieveSecurityTokens.
@Test
public void testRetrieveSecurityTokens() {
// given
PrincipalHolder principalHolder = new PrincipalHolder();
PrincipalCollection principalCollection = new SimplePrincipalCollection();
// when
principalHolder.setPrincipals(principalCollection);
// then
assertThat(principalHolder.getPrincipals(), is(principalCollection));
}
use of org.apache.shiro.subject.SimplePrincipalCollection in project ddf by codice.
the class SessionManagementServiceImplTest method setup.
@Before
public void setup() throws ParserConfigurationException, SAXException, IOException, SecurityServiceException {
request = mock(HttpServletRequest.class);
principalCollection = new SimplePrincipalCollection();
refreshedPrincipalCollection = mock(PrincipalCollection.class);
principalHolderMock = mock(PrincipalHolder.class);
manager = mock(SecurityManager.class);
sessionFactory = mock(SessionFactory.class);
session = mock(HttpSession.class);
Subject subject = mock(Subject.class);
when(request.getSession(false)).thenReturn(session);
when(principalHolderMock.getPrincipals()).thenReturn(principalCollection);
when(manager.getSubject(isA(BaseAuthenticationToken.class))).thenReturn(subject);
when(sessionFactory.getOrCreateSession(any())).thenReturn(session);
when(session.getAttribute(SecurityConstants.SECURITY_TOKEN_KEY)).thenReturn(principalHolderMock);
when(session.getMaxInactiveInterval()).thenReturn(Integer.MAX_VALUE);
when(subject.getPrincipals()).thenReturn(refreshedPrincipalCollection);
sessionManagementServiceImpl = new SessionManagementServiceImpl();
sessionManagementServiceImpl.setSessionFactory(sessionFactory);
}
Aggregations