Search in sources :

Example 1 with Origin

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;
}
Also used : Origin(org.dcache.auth.Origin) KerberosPrincipal(javax.security.auth.kerberos.KerberosPrincipal) GSSException(org.ietf.jgss.GSSException) CacheException(diskCacheV111.util.CacheException) Subject(javax.security.auth.Subject)

Example 2 with Origin

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;
    }
}
Also used : Origin(org.dcache.auth.Origin) Subject(javax.security.auth.Subject)

Example 3 with Origin

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;
}
Also used : Origin(org.dcache.auth.Origin) Subject(javax.security.auth.Subject)

Example 4 with Origin

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);
}
Also used : Origin(org.dcache.auth.Origin) Owner(org.dcache.acl.Owner) READ_ACL(org.dcache.acl.enums.AccessMask.READ_ACL) ACL(org.dcache.acl.ACL) WRITE_ACL(org.dcache.acl.enums.AccessMask.WRITE_ACL) ACL(org.dcache.namespace.FileAttribute.ACL)

Example 5 with Origin

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);
}
Also used : Origin(org.dcache.auth.Origin) UidPrincipal(org.dcache.auth.UidPrincipal) ACLPermissionHandler(org.dcache.namespace.ACLPermissionHandler) Principal(java.security.Principal) UidPrincipal(org.dcache.auth.UidPrincipal) GidPrincipal(org.dcache.auth.GidPrincipal) GidPrincipal(org.dcache.auth.GidPrincipal) Subject(javax.security.auth.Subject) BeforeClass(org.junit.BeforeClass)

Aggregations

Origin (org.dcache.auth.Origin)16 Subject (javax.security.auth.Subject)10 CacheException (diskCacheV111.util.CacheException)5 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)4 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)3 DoorRequestInfoMessage (diskCacheV111.vehicles.DoorRequestInfoMessage)3 InetAddress (java.net.InetAddress)3 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)3 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)3 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)2 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)2 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)2 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)2 FsPath (diskCacheV111.util.FsPath)2 NotDirCacheException (diskCacheV111.util.NotDirCacheException)2 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)2 InetSocketAddress (java.net.InetSocketAddress)2 UnknownHostException (java.net.UnknownHostException)2 Principal (java.security.Principal)2 CertificateException (java.security.cert.CertificateException)2