use of org.dcache.auth.Origin in project dcache by dCache.
the class StrategyIdMapper method login.
@Override
public Subject login(RpcTransport xt, GSSContext gssc) {
try {
KerberosPrincipal principal = new KerberosPrincipal(gssc.getSrcName().toString());
Subject in = new Subject();
in.getPrincipals().add(principal);
in.getPrincipals().add(new Origin(xt.getRemoteSocketAddress().getAddress()));
in.setReadOnly();
return populateWithUnixPrincipals(_remoteLoginStrategy.login(in).getSubject());
} catch (GSSException | CacheException e) {
LOGGER.debug("Failed to login for : {} : {}", gssc, e.toString());
}
return Subjects.NOBODY;
}
use of org.dcache.auth.Origin in project dcache by dCache.
the class DcacheResourceFactory method roleAwareSubject.
private Subject roleAwareSubject() {
Subject subject = getSubject();
if (isAdmin()) {
Origin origin = Subjects.getOrigin(subject);
if (origin == null) {
return Subjects.ROOT;
} else {
Subject adminSubject = new Subject(false, Subjects.ROOT.getPrincipals(), Subjects.ROOT.getPublicCredentials(), Subjects.ROOT.getPrivateCredentials());
adminSubject.getPrincipals().add(origin);
adminSubject.setReadOnly();
return adminSubject;
}
} else {
return subject;
}
}
use of org.dcache.auth.Origin in project dcache by dCache.
the class LoginAuthenticationHandler method addOrigin.
private Subject addOrigin(Subject subject, InetAddress address) {
Subject newSubject;
if (subject == null) {
newSubject = new Subject();
} else {
newSubject = new Subject(false, subject.getPrincipals(), subject.getPublicCredentials(), subject.getPrivateCredentials());
}
newSubject.getPrincipals().add(new Origin(address));
return newSubject;
}
use of org.dcache.auth.Origin in project dcache by dCache.
the class ACLPermissionHandler method getPermission.
private Permission getPermission(Subject subject, FileAttributes attr) {
ACL acl = attr.getAcl();
Owner owner = new Owner(attr.getOwner(), attr.getGroup());
Origin origin = Subjects.getOrigin(subject);
return AclMapper.getPermission(subject, origin, owner, acl);
}
use of org.dcache.auth.Origin in project dcache by dCache.
the class ACLPermissionHandlerSecondTest method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
pdp = new ACLPermissionHandler();
origin = new Origin("127.0.0.1");
Principal user = new UidPrincipal(UID);
Principal group = new GidPrincipal(GID, true);
subject = new Subject();
subject.getPrincipals().add(user);
subject.getPrincipals().add(group);
subject.getPrincipals().add(origin);
}
Aggregations