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

java.lang.Object
  extended by org.opentox.toxotis.util.aa.policy.Policy
All Implemented Interfaces:
IPolicy, IPolicyWrapper

public class Policy
extends Object
implements IPolicy

An authentication/authorization policy defines explicitly the way in which clients are granted permissions to access certain resource and perform HTTP requests. Policies may grant access to certain individuals or subject groups.

Author:
Pantelis Sopasakis, Charalampos Chomenides

Constructor Summary
Policy()
          New empty policy.
Policy(String policyName)
          New policy with a policy name.
 
Method Summary
 void addRule(IPolicyRule rule)
          Add a rule to the current policy.
 void addSubject(PolicySubject subject)
          Add a new Policy Subject.
 Document getDocument()
           
 String getPolicyName()
          The name of the policy.
 String getSubjectsCollectionName()
          The name of the collection of subjects.
 String getSubjectsDescription()
          Description of the subject.
 String getText()
           
 int publish(VRI policyServer, AuthenticationToken token)
          Publish this policy to a remote server and acquire a URI for it.
 void setPolicyName(String policyName)
          Specify the policy name,
 void setSubjectsCollectionName(String subjectsCollectionName)
          Specify the name of the collection of subjects in the policy.
 void setSubjectsDescription(String subjectsDescription)
          Provide some description for the subjects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Policy

public Policy()
New empty policy.


Policy

public Policy(String policyName)
New policy with a policy name.

Parameters:
policyName - Name of the policy as a String.
Method Detail

getText

public String getText()
Specified by:
getText in interface IPolicyWrapper

getDocument

public Document getDocument()
Specified by:
getDocument in interface IPolicyWrapper

getPolicyName

public String getPolicyName()
Description copied from interface: IPolicy
The name of the policy.

Specified by:
getPolicyName in interface IPolicy
Returns:
Policy name as a String.

setPolicyName

public void setPolicyName(String policyName)
Description copied from interface: IPolicy
Specify the policy name,

Specified by:
setPolicyName in interface IPolicy
Parameters:
policyName - A name/title for your policy.

addRule

public void addRule(IPolicyRule rule)
Description copied from interface: IPolicy
Add a rule to the current policy.

Specified by:
addRule in interface IPolicy
Parameters:
rule - A new policy rule to be added.
See Also:
IPolicyRule, IPolicyWrapper

addSubject

public void addSubject(PolicySubject subject)
Description copied from interface: IPolicy
Add a new Policy Subject.

Specified by:
addSubject in interface IPolicy
Parameters:
subject - The new policy subject to be added
See Also:
PolicySubject, SingleSubject, GroupSubject

getSubjectsCollectionName

public String getSubjectsCollectionName()
Description copied from interface: IPolicy
The name of the collection of subjects.

Specified by:
getSubjectsCollectionName in interface IPolicy
Returns:
Subjects' collection name.

setSubjectsCollectionName

public void setSubjectsCollectionName(String subjectsCollectionName)
Description copied from interface: IPolicy
Specify the name of the collection of subjects in the policy.

Specified by:
setSubjectsCollectionName in interface IPolicy
Parameters:
subjectsCollectionName - Name of subjects' collection.

getSubjectsDescription

public String getSubjectsDescription()
Description copied from interface: IPolicy
Description of the subject.

Specified by:
getSubjectsDescription in interface IPolicy
Returns:
Description of the subject as a String.

setSubjectsDescription

public void setSubjectsDescription(String subjectsDescription)
Description copied from interface: IPolicy
Provide some description for the subjects.

Specified by:
setSubjectsDescription in interface IPolicy
Parameters:
subjectsDescription - Description of subjects.

publish

public int publish(VRI policyServer,
                   AuthenticationToken token)
            throws ServiceInvocationException
Publish this policy to a remote server and acquire a URI for it.

Specified by:
publish in interface IPolicyWrapper
Parameters:
policyServer - URI of the policy server. If set to null then the standard policy service of OpenTox at https://opensso.in-silico.ch/pol will be used instead.
token - Token used to authenticate the user that attempts to publish a new policy against the policy service. If you think that no authentication is needed to perform the HTTP request you may set it to null.
Returns:
Server's response message
Throws:
ToxOtisException - In case a HTTP related error occurs (I/O communication error, or the remote server is down), the service respondes in an unexpected manner like a status code 500 or 503 or authentication/authorization fails and a status code 403 or 401 are returned respectively.
InactiveTokenException - If the token the user uses is not active (because it has been invalidated, expired, or not initialized yet).
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.