public class DownloadGateKeeper extends Object implements GateKeeper
Any resource granted permissions for will be normalised to remove any part of the path before the first
occurrence of the text download
. So /confluence/download/foo.txt
will need to be checked
as download/foo.txt
. Attempts to grant permission to a path that doesn't contain "download" will throw
an exception.
Permissions will be expired 24 hours after they are granted.
Constructor and Description |
---|
DownloadGateKeeper() |
Modifier and Type | Method and Description |
---|---|
void |
addKey(String path,
String username)
Add permission for a user to access a certain path.
|
void |
addKey(String path,
com.atlassian.user.User user)
Permit a user to download a particular resource.
|
void |
allowAnonymousAccess(String path)
Allow all users, including the anonymous user, access to a particular path.
|
void |
cleanAllKeys()
Revoke all granted permissions.
|
void |
cleanAllKeysOlderThan(long millis) |
boolean |
isAccessPermitted(String path,
String userName)
Determine whether a user is permitted to access a resource.
|
boolean |
isAccessPermitted(String path,
com.atlassian.user.User user)
Determine whether a user is permitted to access a resource.
|
public void addKey(String path, String username)
/confluence/download/Foo
will be
normalised to download/Foo
. If the text "download" does not appear in the path, an exception
will be thrownaddKey
in interface GateKeeper
username
- the username of the user to be permitted. null
represents the name of
the anonymous users.path
- the path being granted permission to. Must not be null.IllegalArgumentException
- if the path is not of the expected formpublic void addKey(String path, com.atlassian.user.User user)
GateKeeper
addKey
in interface GateKeeper
path
- the path to the resource being made accessibleuser
- the user to grant permission for. null
may be used to represent anonymous users.public void allowAnonymousAccess(String path)
addKey(java.lang.String, java.lang.String)
allowAnonymousAccess
in interface GateKeeper
path
- The resource to grant access permission topublic boolean isAccessPermitted(String path, com.atlassian.user.User user)
GateKeeper
isAccessPermitted
in interface GateKeeper
path
- the path to the resource being requesteduser
- the user requesting permission to retrieve that resourcepublic boolean isAccessPermitted(String path, String userName)
GateKeeper
isAccessPermitted
in interface GateKeeper
path
- the path to the resource being requesteduserName
- the name of the user requesting permission to retrieve that resourcepublic void cleanAllKeys()
GateKeeper
cleanAllKeys
in interface GateKeeper
public void cleanAllKeysOlderThan(long millis)
Copyright © 2003–2017 Atlassian. All rights reserved.