use of org.apache.shiro.subject.PrincipalCollection 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.PrincipalCollection 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.PrincipalCollection in project ddf by codice.
the class SubjectUtilsTest method getSubjectWithPrincipal.
private ddf.security.Subject getSubjectWithPrincipal(Principal principal) {
ddf.security.Subject subject = mock(ddf.security.Subject.class);
PrincipalCollection pc = mock(PrincipalCollection.class);
SecurityAssertion assertion = mock(SecurityAssertion.class);
doReturn(pc).when(subject).getPrincipals();
doReturn(Collections.singletonList(assertion)).when(pc).byType(SecurityAssertion.class);
doReturn(ImmutableList.of(assertion)).when(pc).byType(SecurityAssertion.class);
doReturn(principal).when(assertion).getPrincipal();
return subject;
}
use of org.apache.shiro.subject.PrincipalCollection 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.PrincipalCollection 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));
}
Aggregations