Search in sources :

Example 1 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class PrefixProfileFactory method create.

@Override
public T create(Map<String, String> arguments) {
    String prefixConfig = arguments.get("prefix");
    if (prefixConfig == null) {
        throw new IllegalArgumentException("Missing 'prefix' argument.");
    }
    if (!prefixConfig.startsWith("/")) {
        throw new IllegalArgumentException("Path in 'prefix' is not absolute: must start with '/'");
    }
    FsPath prefix = FsPath.create(prefixConfig);
    return createProfile(prefix, arguments);
}
Also used : FsPath(diskCacheV111.util.FsPath)

Example 2 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class ScopeBasedAuthzProfile method buildRestriction.

private Restriction buildRestriction(List<AuthorisationSupplier> scopes) {
    Map<FsPath, MultiTargetedRestriction.Authorisation> authorisations = new HashMap<>();
    scopes.stream().map(s -> s.authorisation(prefix)).filter(Optional::isPresent).map(Optional::get).forEach(a -> {
        FsPath path = a.getPath();
        MultiTargetedRestriction.Authorisation existing = authorisations.get(path);
        if (existing != null) {
            Collection<Activity> combined = EnumSet.copyOf(existing.getActivity());
            combined.addAll(a.getActivity());
            a = new MultiTargetedRestriction.Authorisation(combined, path);
        }
        authorisations.put(path, a);
    });
    return new MultiTargetedRestriction(authorisations.values());
}
Also used : ExemptFromNamespaceChecks(org.dcache.auth.ExemptFromNamespaceChecks) MultiTargetedRestriction(org.dcache.auth.attributes.MultiTargetedRestriction) FsPath(diskCacheV111.util.FsPath) Preconditions.checkAuthentication(org.dcache.gplazma.util.Preconditions.checkAuthentication) Restriction(org.dcache.auth.attributes.Restriction) Collection(java.util.Collection) Set(java.util.Set) HashMap(java.util.HashMap) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) AuthenticationException(org.dcache.gplazma.AuthenticationException) ProfileResult(org.dcache.gplazma.oidc.ProfileResult) List(java.util.List) Principal(java.security.Principal) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) Activity(org.dcache.auth.attributes.Activity) Optional(java.util.Optional) JsonNode(com.fasterxml.jackson.databind.JsonNode) Collections(java.util.Collections) IdentityProvider(org.dcache.gplazma.oidc.IdentityProvider) EnumSet(java.util.EnumSet) Optional(java.util.Optional) HashMap(java.util.HashMap) MultiTargetedRestriction(org.dcache.auth.attributes.MultiTargetedRestriction) Activity(org.dcache.auth.attributes.Activity) FsPath(diskCacheV111.util.FsPath)

Example 3 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class WlcgProfileScope method authorisation.

@Override
public Optional<MultiTargetedRestriction.Authorisation> authorisation(FsPath prefix) {
    FsPath absPath = prefix.resolve(path.substring(1));
    LOGGER.debug("WlcgProfileScope authorising {} with prefix \"{}\" to path {}", prefix, operation.allowedActivities, absPath);
    return Optional.of(new Authorisation(operation.allowedActivities, absPath));
}
Also used : Authorisation(org.dcache.auth.attributes.MultiTargetedRestriction.Authorisation) FsPath(diskCacheV111.util.FsPath)

Example 4 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class XrootdDoor method deleteFile.

/**
 * Delete the file denoted by path from the namespace
 *
 * @param path The path of the file that is going to be deleted
 * @throws CacheException                 Deletion of the file failed
 * @throws PermissionDeniedCacheException Caller does not have permission to delete the file
 */
public void deleteFile(FsPath path, Subject subject, Restriction restriction) throws PermissionDeniedCacheException, CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    if (!isWriteAllowed(path)) {
        throw new PermissionDeniedCacheException("Write permission denied");
    }
    Set<FileType> allowedSet = EnumSet.of(FileType.REGULAR);
    PnfsId pnfsId = pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
    sendRemoveInfoToBilling(pnfsId, path, subject);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsId(diskCacheV111.util.PnfsId) PnfsHandler(diskCacheV111.util.PnfsHandler)

Example 5 with FsPath

use of diskCacheV111.util.FsPath in project dcache by dCache.

the class XrootdDoor method deleteDirectory.

/**
 * Delete the directory denoted by path from the namespace
 *
 * @param path The path of the directory that is going to be deleted
 * @throws CacheException
 */
public void deleteDirectory(FsPath path, Subject subject, Restriction restriction) throws CacheException {
    PnfsHandler pnfsHandler = new PnfsHandler(_pnfs, subject, restriction);
    if (!isWriteAllowed(path)) {
        throw new PermissionDeniedCacheException("Write permission denied");
    }
    Set<FileType> allowedSet = EnumSet.of(FileType.DIR);
    pnfsHandler.deletePnfsEntry(path.toString(), allowedSet);
}
Also used : PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) FileType(org.dcache.namespace.FileType) PnfsHandler(diskCacheV111.util.PnfsHandler)

Aggregations

FsPath (diskCacheV111.util.FsPath)98 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)66 CacheException (diskCacheV111.util.CacheException)63 FileNotFoundCacheException (diskCacheV111.util.FileNotFoundCacheException)56 FileExistsCacheException (diskCacheV111.util.FileExistsCacheException)43 NotDirCacheException (diskCacheV111.util.NotDirCacheException)42 TimeoutCacheException (diskCacheV111.util.TimeoutCacheException)39 FileAttributes (org.dcache.vehicles.FileAttributes)32 PnfsHandler (diskCacheV111.util.PnfsHandler)26 NotFileCacheException (diskCacheV111.util.NotFileCacheException)25 FileIsNewCacheException (diskCacheV111.util.FileIsNewCacheException)23 FileAttribute (org.dcache.namespace.FileAttribute)22 MissingResourceCacheException (diskCacheV111.util.MissingResourceCacheException)21 FileCorruptedCacheException (diskCacheV111.util.FileCorruptedCacheException)20 Subject (javax.security.auth.Subject)17 Restriction (org.dcache.auth.attributes.Restriction)17 Test (org.junit.Test)17 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)15 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)14 SRMException (org.dcache.srm.SRMException)14