Search in sources :

Example 1 with UserNamePrincipal

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

the class StrategyIdMapper method principalToUid.

@Override
public int principalToUid(String name) {
    try {
        String principal = stripDomain(name);
        Principal uidPrincipal = _remoteLoginStrategy.map(new UserNamePrincipal(principal));
        if (uidPrincipal instanceof UidPrincipal) {
            return (int) ((UidPrincipal) uidPrincipal).getUid();
        }
    } catch (CacheException e) {
        LOGGER.debug("Failed to map principal {} : {}", name, e);
    }
    return tryNumericIfAllowed(name);
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) CacheException(diskCacheV111.util.CacheException) UidPrincipal(org.dcache.auth.UidPrincipal) GroupNamePrincipal(org.dcache.auth.GroupNamePrincipal) GidPrincipal(org.dcache.auth.GidPrincipal) KerberosPrincipal(javax.security.auth.kerberos.KerberosPrincipal) UserNamePrincipal(org.dcache.auth.UserNamePrincipal) Principal(java.security.Principal) UidPrincipal(org.dcache.auth.UidPrincipal)

Example 2 with UserNamePrincipal

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

the class Nsswitch method map.

@Override
public void map(Set<Principal> principals) throws AuthenticationException {
    __password password = null;
    boolean havePrimaryGid = false;
    for (Principal p : principals) {
        if (p instanceof UserNamePrincipal && password == null) {
            password = _libc.getpwnam(p.getName());
        } else if (p instanceof GidPrincipal) {
            havePrimaryGid |= ((GidPrincipal) p).isPrimaryGroup();
        }
    }
    checkAuthentication(password != null, "no mapping");
    principals.add(new UidPrincipal(password.uid));
    principals.add(new GidPrincipal(password.gid, !havePrimaryGid));
    for (int id : groupsOf(password)) {
        principals.add(new GidPrincipal(id, false));
    }
}
Also used : UserNamePrincipal(org.dcache.auth.UserNamePrincipal) UidPrincipal(org.dcache.auth.UidPrincipal) UserNamePrincipal(org.dcache.auth.UserNamePrincipal) Principal(java.security.Principal) UidPrincipal(org.dcache.auth.UidPrincipal) GroupNamePrincipal(org.dcache.auth.GroupNamePrincipal) GidPrincipal(org.dcache.auth.GidPrincipal) GidPrincipal(org.dcache.auth.GidPrincipal)

Example 3 with UserNamePrincipal

use of org.dcache.auth.UserNamePrincipal 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 4 with UserNamePrincipal

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

the class GplazmaMultiMapFileTest method shouldPassWhenOidcMappedWithoutOP.

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

Example 5 with UserNamePrincipal

use of org.dcache.auth.UserNamePrincipal 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)

Aggregations

UserNamePrincipal (org.dcache.auth.UserNamePrincipal)26 Principal (java.security.Principal)14 GidPrincipal (org.dcache.auth.GidPrincipal)12 UidPrincipal (org.dcache.auth.UidPrincipal)11 Test (org.junit.Test)9 GroupNamePrincipal (org.dcache.auth.GroupNamePrincipal)7 HashSet (java.util.HashSet)4 KerberosPrincipal (javax.security.auth.kerberos.KerberosPrincipal)4 EmailAddressPrincipal (org.dcache.auth.EmailAddressPrincipal)4 LoginNamePrincipal (org.dcache.auth.LoginNamePrincipal)4 OidcSubjectPrincipal (org.dcache.auth.OidcSubjectPrincipal)4 AuthenticationException (org.dcache.gplazma.AuthenticationException)4 Subject (javax.security.auth.Subject)3 GlobusPrincipal (org.globus.gsi.gssapi.jaas.GlobusPrincipal)3 UserPrincipal (com.sun.security.auth.UserPrincipal)2 NamingException (javax.naming.NamingException)2 BasicAttributes (javax.naming.directory.BasicAttributes)2 SearchResult (javax.naming.directory.SearchResult)2 LoginGidPrincipal (org.dcache.auth.LoginGidPrincipal)2 PasswordCredential (org.dcache.auth.PasswordCredential)2