public class

DownloadGateKeeper

extends Object
implements GateKeeper
java.lang.Object
   ↳ com.atlassian.confluence.security.DownloadGateKeeper

Class Overview

GateKeeper for the Confluence downloads directory.

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.

Summary

Public Constructors
DownloadGateKeeper()
Public Methods
void addKey(String path, String username)
Add permission for a user to access a certain path.
void addKey(String path, 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, User user)
Determine whether a user is permitted to access a resource.
boolean isAccessPermitted(String path, String userName)
Determine whether a user is permitted to access a resource.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.confluence.security.GateKeeper

Public Constructors

public DownloadGateKeeper ()

Public Methods

public void addKey (String path, String username)

Add permission for a user to access a certain path. The path will be normalised on the way in so that anything before the text "download' is discarded. So /confluence/download/Foo will be normalised to download/Foo. If the text "download" does not appear in the path, an exception will be thrown

Parameters
path the path being granted permission to. Must not be null.
username the username of the user to be permitted. null represents the name of the anonymous users.
Throws
IllegalArgumentException if the path is not of the expected form

public void addKey (String path, User user)

Permit a user to download a particular resource. This permission is temporary, and may expire after whatever time period the GateKeeper thinks is reasonable.

Parameters
path the path to the resource being made accessible
user the user to grant permission for. null may be used to represent anonymous users.

public void allowAnonymousAccess (String path)

Allow all users, including the anonymous user, access to a particular path. The path will be normalised to the same rules as addKey(String, User)

Parameters
path The resource to grant access permission to

public void cleanAllKeys ()

Revoke all granted permissions.

public void cleanAllKeysOlderThan (long millis)

public boolean isAccessPermitted (String path, User user)

Determine whether a user is permitted to access a resource.

Parameters
path the path to the resource being requested
user the user requesting permission to retrieve that resource
Returns
  • true if the user is permitted to retrieve that resource, false otherwise

public boolean isAccessPermitted (String path, String userName)

Determine whether a user is permitted to access a resource.

Parameters
path the path to the resource being requested
userName the name of the user requesting permission to retrieve that resource
Returns
  • true if the user is permitted to retrieve that resource, false otherwise