Search in sources :

Example 1 with EmailAddressPrincipal

use of org.dcache.auth.EmailAddressPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldFailWhenWrongMapFormatEmail2.

@Test
public void shouldFailWhenWrongMapFormatEmail2() throws Exception {
    givenConfig("email:kermit.dcache.org    username:kermit");
    whenMapping(new EmailAddressPrincipal("kermit@dcache.org"));
    assertThat(warnings, is(not(empty())));
    assertThat(mappedPrincipals, is(empty()));
}
Also used : EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) Test(org.junit.Test)

Example 2 with EmailAddressPrincipal

use of org.dcache.auth.EmailAddressPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method testRefresh.

@Test
public void testRefresh() throws Exception {
    givenConfig("  \n");
    givenConfigHasBeenRead();
    givenConfig("email:kermit@dcache.org    username:kermit\n");
    whenMapping(new EmailAddressPrincipal("kermit@dcache.org"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, hasItem(new UserNamePrincipal("kermit")));
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) Test(org.junit.Test)

Example 3 with EmailAddressPrincipal

use of org.dcache.auth.EmailAddressPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldPassWhenEmailMapped.

@Test
public void shouldPassWhenEmailMapped() throws Exception {
    givenConfig("email:kermit@dcache.org    username:kermit");
    whenMapping(new EmailAddressPrincipal("kermit@dcache.org"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, hasItem(new UserNamePrincipal("kermit")));
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) Test(org.junit.Test)

Example 4 with EmailAddressPrincipal

use of org.dcache.auth.EmailAddressPrincipal in project dcache by dCache.

the class GplazmaMultiMapFileTest method shouldPassWhenEmailMapped2.

@Test
public void shouldPassWhenEmailMapped2() throws Exception {
    givenConfig("\"email:kermit@dcache.org\"    \"username:kermit\"");
    whenMapping(new EmailAddressPrincipal("kermit@dcache.org"));
    assertThat(warnings, is(empty()));
    assertThat(mappedPrincipals, hasItem(new UserNamePrincipal("kermit")));
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) Test(org.junit.Test)

Example 5 with EmailAddressPrincipal

use of org.dcache.auth.EmailAddressPrincipal in project dcache by dCache.

the class X509Plugin method identifyPrincipalsFromEEC.

private List<Principal> identifyPrincipalsFromEEC(X509Certificate eec) throws AuthenticationException, CertificateParsingException {
    Set<Principal> caPrincipals = identifyPrincipalsFromIssuer(eec);
    List<String> policies = listPolicies(eec);
    List<Principal> loaPrincipals = policies.stream().flatMap(X509Plugin::loaPrincipals).collect(Collectors.toList());
    Collection<List<?>> san = listSubjectAlternativeNames(eec);
    List<Principal> emailPrincipals = subjectAlternativeNamesWithTag(san, GeneralName.rfc822Name).filter(EmailAddressPrincipal::isValid).map(EmailAddressPrincipal::new).collect(Collectors.toList());
    Principal subject = new GlobusPrincipal(eec.getSubjectX500Principal());
    Optional<EntityDefinition> entity = identifyEntityDefinition(eec, policies, subject, san);
    List<Principal> principals = new ArrayList<>();
    principals.addAll(caPrincipals);
    principals.addAll(loaPrincipals);
    principals = filterOutErroneousLoAs(subject, principals);
    addImpliedLoA(entity, principals);
    principals.add(subject);
    principals.addAll(emailPrincipals);
    entity.map(EntityDefinitionPrincipal::new).ifPresent(principals::add);
    return principals;
}
Also used : GlobusPrincipal(org.globus.gsi.gssapi.jaas.GlobusPrincipal) ArrayList(java.util.ArrayList) EntityDefinition(org.dcache.auth.EntityDefinition) List(java.util.List) ArrayList(java.util.ArrayList) EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) EmailAddressPrincipal(org.dcache.auth.EmailAddressPrincipal) GlobusPrincipal(org.globus.gsi.gssapi.jaas.GlobusPrincipal) Principal(java.security.Principal) EntityDefinitionPrincipal(org.dcache.auth.EntityDefinitionPrincipal) LoAPrincipal(org.dcache.auth.LoAPrincipal)

Aggregations

EmailAddressPrincipal (org.dcache.auth.EmailAddressPrincipal)8 Test (org.junit.Test)6 UserNamePrincipal (org.dcache.auth.UserNamePrincipal)4 Principal (java.security.Principal)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Subject (javax.security.auth.Subject)1 EntityDefinition (org.dcache.auth.EntityDefinition)1 EntityDefinitionPrincipal (org.dcache.auth.EntityDefinitionPrincipal)1 LoAPrincipal (org.dcache.auth.LoAPrincipal)1 GlobusPrincipal (org.globus.gsi.gssapi.jaas.GlobusPrincipal)1