use of org.dcache.auth.GidPrincipal in project dcache by dCache.
the class StrategyIdMapper method principalToGid.
@Override
public int principalToGid(String name) {
try {
String principal = stripDomain(name);
Principal gidPrincipal = _remoteLoginStrategy.map(new GroupNamePrincipal(principal));
if (gidPrincipal instanceof GidPrincipal) {
return (int) ((GidPrincipal) gidPrincipal).getGid();
}
} catch (CacheException e) {
LOGGER.debug("Failed to map principal {} : {}", name, e);
}
return tryNumericIfAllowed(name);
}
use of org.dcache.auth.GidPrincipal in project dcache by dCache.
the class Nis method map.
@Override
public void map(Set<Principal> principals) throws AuthenticationException {
boolean mapped;
Principal principal = find(principals, instanceOf(UserNamePrincipal.class), null);
checkAuthentication(principal != null, "no username principal");
try {
Attributes userAttr = _ctx.getAttributes(NISMAP_PASSWORD_BY_NAME + "/" + principal.getName());
principals.add(new UidPrincipal((String) userAttr.get(UID_NUMBER_ATTRIBUTE).get()));
principals.add(new GidPrincipal((String) userAttr.get(GID_NUMBER_ATTRIBUTE).get(), true));
NamingEnumeration<SearchResult> groupResult = _ctx.search(NISMAP_GROUP_BY_NAME, new BasicAttributes(MEMBER_UID_ATTRIBUTE, principal.getName()));
mapped = true;
while (groupResult.hasMore()) {
SearchResult result = groupResult.next();
principals.add(new GidPrincipal((String) result.getAttributes().get(GID_NUMBER_ATTRIBUTE).get(), false));
}
} catch (NamingException e) {
LOGGER.debug("Failed to get mapping: {}", e.toString());
throw new AuthenticationException("no mapping: " + e.getMessage(), e);
}
checkAuthentication(mapped, "no matching principal");
}
use of org.dcache.auth.GidPrincipal 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.GidPrincipal in project dcache by dCache.
the class GplazmaMultiMapFileTest method shouldMatchNonPrimarySpecificGroupWithNonPrimaryGroup.
@Test
public void shouldMatchNonPrimarySpecificGroupWithNonPrimaryGroup() throws Exception {
givenConfig("group:test gid:1000,false");
whenMapping(new GroupNamePrincipal("test", false));
assertThat(warnings, is(empty()));
assertThat(mappedPrincipals, hasItem(new GidPrincipal(1000, false)));
}
use of org.dcache.auth.GidPrincipal in project dcache by dCache.
the class GplazmaMultiMapFileTest method shouldMatchNonPrimarySpecificGroupWithPrimaryGroup.
@Test
public void shouldMatchNonPrimarySpecificGroupWithPrimaryGroup() throws Exception {
givenConfig("group:test gid:1000,false");
whenMapping(new GroupNamePrincipal("test", true));
assertThat(warnings, is(empty()));
assertThat(mappedPrincipals, hasItem(new GidPrincipal(1000, false)));
}
Aggregations