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);
}
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));
}
}
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")));
}
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")));
}
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")));
}
Aggregations