org.opentox.toxotis.util.aa.policy
Class PolicyManager

java.lang.Object
  extended by org.opentox.toxotis.util.aa.policy.PolicyManager

public final class PolicyManager
extends Object

Utilities for policy creation, deletion and parsing.

Author:
Pantelis Sopasakis, Charalampos Chomenides

Method Summary
static IPolicyWrapper defaultSignleUserPolicy(String policyName, VRI componentUri, AuthenticationToken token)
           
static IPolicyWrapper defaultSignleUserPolicy(String policyName, VRI componentUri, String userName)
          Creates the default policy for a user.
static void deleteAllMyPolicies(VRI policyService, AuthenticationToken token)
          Delete all
static void deleteRemotePolicy(VRI policyServiceUri, String policyName, AuthenticationToken token)
           
static String getPolicyOwner(VRI resourceUri, VRI policyService, AuthenticationToken token)
          Obtain the username of the owner of a policy for a given URI.
static List<String> listPolicyUris(VRI policyService, AuthenticationToken token)
          List all policies that are hosted in the provided policy service.
static IPolicyWrapper parsePolicy(String id, VRI policyService, AuthenticationToken token)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

deleteRemotePolicy

public static void deleteRemotePolicy(VRI policyServiceUri,
                                      String policyName,
                                      AuthenticationToken token)
                               throws ServiceInvocationException
Throws:
ServiceInvocationException

deleteAllMyPolicies

public static void deleteAllMyPolicies(VRI policyService,
                                       AuthenticationToken token)
                                throws ServiceInvocationException
Delete all

Parameters:
policyService -
token -
Throws:
ToxOtisException
ServiceInvocationException

getPolicyOwner

public static String getPolicyOwner(VRI resourceUri,
                                    VRI policyService,
                                    AuthenticationToken token)
                             throws ServiceInvocationException
Obtain the username of the owner of a policy for a given URI.

Parameters:
resourceUri - URI of an (OpenTox) resource for which the username of its creator is requested.
policyService - URI of the SSO service used to carry out our request. In case this argument is set to null, the default SSO service URI https://opensso.in-silico.ch/pol will be used instead.
token - Authentication token used to grant you access to the policy management service.
Returns:
The owner/creator of the policy for the provided service URI or null if this URI is not registered to the policy service and does not have a policy.
Throws:
ToxOtisException - In case authentication/authorization against the SSO service fails due to invalid token or insufficient priviledges or the service has encoutnered some unexpected internal condition (status code 500). The OpenTox REST API specifies that the range of possible status codes includes 200 (OK, Successs), 401 (Unauthorized) and 500 (other unexpected conditions).
InactiveTokenException - If the token the user uses is not active (because it has been invalidated, expired, or not initialized yet).
ServiceInvocationException

listPolicyUris

public static List<String> listPolicyUris(VRI policyService,
                                          AuthenticationToken token)
                                   throws ServiceInvocationException
List all policies that are hosted in the provided policy service.

Parameters:
policyService - Policy service in which this method will search for registered policies. If set to null then the standard policy service at https://opensso.in-silico.ch/pol will be automatically chosen.
token - Token URI used to authenticate the client against the opensso service and acquire permissions to get the list of policies!
Returns:
A list of policy IDs that are hosted in the SSO service by the user that is identified by the provided authenticaton token. Note that the IDs of policies are not URIs.
Throws:
ToxOtisException - In case authentication/authorization fails, so the client does not have acceess privileges to the remote service, or the provided URI of the policyService is not found or the service responds with an error status code or exhibits some unexpected behavior. According to the OpenTox API, possible status codes include 200, 401/403 and 500.
InactiveTokenException - If the token the user uses is not active (because it has been invalidated, expired, or not initialized yet).
ServiceInvocationException

parsePolicy

public static IPolicyWrapper parsePolicy(String id,
                                         VRI policyService,
                                         AuthenticationToken token)
                                  throws ServiceInvocationException
Throws:
ServiceInvocationException

defaultSignleUserPolicy

public static IPolicyWrapper defaultSignleUserPolicy(String policyName,
                                                     VRI componentUri,
                                                     String userName)
Creates the default policy for a user. If the user if guest then the created policy allows everyone to access the resource (it is made public). In any other case, only the creator has access to the resource. By default, the policy allows users to GET, POST, PUT and DELETE.

Parameters:
policyName - Name of the policy to be created (has to be unique).
componentUri - The URI of the resource for which the policy is created.
userName - The name of the user to which the privileges are assigned.
Returns:
A Policy which can be published to the policy server.

defaultSignleUserPolicy

public static IPolicyWrapper defaultSignleUserPolicy(String policyName,
                                                     VRI componentUri,
                                                     AuthenticationToken token)
                                              throws ToxOtisException,
                                                     ServiceInvocationException
Throws:
ToxOtisException
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.