|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.wso2.registry.secure.SecureRegistry
public class SecureRegistry
Registry implementation to perform authentication and authorization. Each user should use a separate instance of the SecureRegistry initialized with the user name and a back-end Registry. All SecureRegistry instances should be initialized using the same back-end registry implementation. SecureRegistry verifies whether the user has necessary permissions to perform the requested action and delegates the request to the back-end registry if the authorization succeeds. It also sets user name as a thread local variable before delegating the request, so that the back-end registry can use that user name to associate user information with performed operation (e.g. who commented on the resource /projects/abcbank/orders.doc). Resource path is used as the unique ID of the resource to associate permissions. So when an operation is request on a certain path, we can first check the permissions for that path, without even touching the actual resource. This has a side effect that if a user has requested an operation on a non-existing resource, he gets an unauthorized operation message rather than a resource does not exist message. This is good as we don't want unauthorized users to check if a resource exist in a particular path.
Constructor Summary | |
---|---|
SecureRegistry(java.lang.String userID,
java.lang.String password,
Registry registry,
org.wso2.usermanager.Realm defaultRealm)
|
Method Summary | |
---|---|
void |
addComment(java.lang.String resourcePath,
Comment comment)
Adds a comment to a resource. |
void |
applyTag(java.lang.String resourcePath,
java.lang.String tag)
Applies the given tag to the resource in the given path. |
void |
delete(java.lang.String path)
Deletes the resource in the given path. |
Resource |
executeQuery(java.lang.String path,
java.lang.Object[] parameters)
Executes a custom query defined by users. |
Resource |
get(java.lang.String path)
Returns the resource in the given path. |
float |
getAverageRating(java.lang.String resourcePath)
Returns the avarage rating for the given resource. |
Comment[] |
getComments(java.lang.String resourcePath)
Retruns all comments for the given resource. |
LogEntry[] |
getLogs(java.lang.String resourcePath,
int action,
java.lang.String userName,
java.util.Date from,
java.util.Date to)
Returns the logs of the activities occured in the registy. |
int |
getRating(java.lang.String path,
java.lang.String userName)
Returns the rating given to the specified resource by the given user |
TaggedResourcePath[] |
getResourcePathsWithTag(java.lang.String tag)
Returns the paths of the resources, which are tagged using the given tag. |
Tag[] |
getTags(java.lang.String resourcePath)
Returns all tags used for tagging the given resource. |
java.lang.String |
getUserID()
|
RegistryUserManager |
getUserManager()
|
java.lang.String[] |
getVersions(java.lang.String path)
Returns the paths of the versions of the resource located at the given path. |
void |
put(java.lang.String path,
Resource resource)
Checks if the user has "PUT" permissions to the existing ascendent path of the given path. |
void |
rateResource(java.lang.String resourcePath,
int rating)
Rates the given resource. |
void |
removeTag(java.lang.String path,
java.lang.String tag)
Removes a tag on a resource. |
boolean |
resourceExists(java.lang.String path)
Check whether a resource exist in the given path |
void |
restoreVersion(java.lang.String versionPath)
Reverts a resource to a given version. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SecureRegistry(java.lang.String userID, java.lang.String password, Registry registry, org.wso2.usermanager.Realm defaultRealm) throws RegistryException
RegistryException
Method Detail |
---|
public java.lang.String getUserID()
public RegistryUserManager getUserManager()
public Resource get(java.lang.String path) throws RegistryException
Registry
get
in interface Registry
path
- Path of the resource. e.g. /project1/server/deployment.xml
RegistryException
- is thrown if the resource is not in the
registrypublic boolean resourceExists(java.lang.String path) throws RegistryException
Registry
resourceExists
in interface Registry
path
- Path of the resource to be checked
RegistryException
- if an error occurspublic void put(java.lang.String path, Resource resource) throws RegistryException
put
in interface Registry
path
- Path to put the new resourceresource
- New resource
RegistryException
public void delete(java.lang.String path) throws RegistryException
Registry
delete
in interface Registry
path
- Path of the resource to be deleted.
RegistryException
- is thrown depending on the implementation.public java.lang.String[] getVersions(java.lang.String path) throws RegistryException
Registry
getVersions
in interface Registry
path
- Path of a current version of a resource
RegistryException
- if there is an errorpublic void restoreVersion(java.lang.String versionPath) throws RegistryException
Registry
restoreVersion
in interface Registry
versionPath
- path of the version to be reverted. It is not necessary to provide the
path of the resource as it can be derived from the version path.
RegistryException
- if there is an errorpublic void applyTag(java.lang.String resourcePath, java.lang.String tag) throws RegistryException
Registry
applyTag
in interface Registry
resourcePath
- Path of the resource to be tagged.tag
- Tag. Any string can be used for the tag.
RegistryException
- is thrown if a resource does not exist in the given path.public TaggedResourcePath[] getResourcePathsWithTag(java.lang.String tag) throws RegistryException
Registry
getResourcePathsWithTag
in interface Registry
tag
- Tag
RegistryException
- if an error occurspublic Tag[] getTags(java.lang.String resourcePath) throws RegistryException
Registry
getTags
in interface Registry
resourcePath
- Path of the resource
RegistryException
- is thrown if a resource does not exist in the given path.public void removeTag(java.lang.String path, java.lang.String tag) throws RegistryException
Registry
removeTag
in interface Registry
path
- Resource path tagged with the given tag.tag
- Name of the tag to be removed.
RegistryException
- if there's a problempublic void addComment(java.lang.String resourcePath, Comment comment) throws RegistryException
Registry
addComment
in interface Registry
resourcePath
- Path of the resource to add the comment.comment
- Comment instance for the new comment.
RegistryException
- is thrown if a resource does not exist in the given path.public Comment[] getComments(java.lang.String resourcePath) throws RegistryException
Registry
getComments
in interface Registry
resourcePath
- Path of the resource.
RegistryException
- if an error occurspublic void rateResource(java.lang.String resourcePath, int rating) throws RegistryException
Registry
rateResource
in interface Registry
resourcePath
- Path of the resource.rating
- rating value between 1 and 5.
RegistryException
- is thrown if a resource does not exist in the given path.public float getAverageRating(java.lang.String resourcePath) throws RegistryException
Registry
getAverageRating
in interface Registry
resourcePath
- Path of the resource.
RegistryException
- if an error occurspublic int getRating(java.lang.String path, java.lang.String userName) throws RegistryException
Registry
getRating
in interface Registry
path
- Path of the resourceuserName
- username of the user
RegistryException
- if there is a problempublic Resource executeQuery(java.lang.String path, java.lang.Object[] parameters) throws RegistryException
Registry
executeQuery
in interface Registry
path
- Path of the query to execute.parameters
- Query parameters.
RegistryException
- depends on the implementation.public LogEntry[] getLogs(java.lang.String resourcePath, int action, java.lang.String userName, java.util.Date from, java.util.Date to) throws RegistryException
Registry
getLogs
in interface Registry
resourcePath
- If given, only the logs related to the resource path will be returned.
If null, logs for all resources will be returned.action
- Only the logs pertaining to this action will be returned.userName
- If given, only the logs for activities done by the given user will be
returned. If null, logs for all users will be returned.from
- If given, logs for activities occured after the given date will be returned. If
null, there will not be a bound for the starting date.to
- If given, logs for activities occured before the given date will be returned. If
null, there will not be a bound for the ending date.
RegistryException
- if there is a problem
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |