Skip to content

Commit 8de0c43

Browse files
DmitryLitvintsevmksahakyan
authored andcommitted
webdav: return 403 on unauthorized attempt to rename resource
Motivation: ----------- WebDAV returns 500 on unauthorized attempt to rename resource, like so: Internal problem: CacheException(rc=10018;msg=Restriction Restrict[MANAGE,UPLOAD,DELETE,UPDATE_METADATA,STAGE] denied activity MANAGE on ...) Modification: ------------ Handle CacheException in dCacheResource.moveTo method Result: ------- Return 403 on unauthorized attempt to rename resource, like so: Ticket: #7879 Target: trunk Request: 11.1, 11.0, 10.2 Acked-by: Tigran Require-book: no Require-notes: yes
1 parent f9747cd commit 8de0c43

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

modules/dcache-webdav/src/main/java/org/dcache/webdav/DcacheResource.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.milton.http.LockToken;
1313
import io.milton.http.Request;
1414
import io.milton.http.Response;
15+
import io.milton.http.exceptions.BadRequestException;
1516
import io.milton.http.exceptions.ConflictException;
1617
import io.milton.http.exceptions.NotAuthorizedException;
1718
import io.milton.property.PropertySource;
@@ -115,7 +116,7 @@ public int compareTo(DcacheResource that) {
115116

116117
@Override
117118
public void moveTo(CollectionResource newParent, String name)
118-
throws ConflictException {
119+
throws ConflictException, NotAuthorizedException, BadRequestException {
119120
if (!(newParent instanceof DcacheDirectoryResource)) {
120121
throw new RuntimeException(
121122
"Destination is an unknown type. Must be a DcacheDirectoryResource, is a: "
@@ -128,8 +129,10 @@ public void moveTo(CollectionResource newParent, String name)
128129
FsPath newPath = directory._path.child(name);
129130
_factory.move(_path, _attributes.getPnfsId(), newPath);
130131
_path = newPath;
132+
} catch (PermissionDeniedCacheException e) {
133+
throw WebDavExceptions.permissionDenied(this);
131134
} catch (CacheException e) {
132-
throw new RuntimeException(e);
135+
throw new WebDavException(e.getMessage(), e, this);
133136
}
134137
}
135138

0 commit comments

Comments
 (0)