|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.waveset.policy.PolicyImplementation
Interface for classes that implement "policies". These will be the implementation classes behind the Policy objects stored in the repository.
I decided to make this an abstract class rather than interface so we could supply a collection of utility methods that most concrete subclasses will need.
A policy in the simplest case is just a validation function for a field in some object. In early prototyping, policies were "rules" which were functions of more than one value. This got lost along the way. If we want to resurect the notion that policies can be fed more than one value, they will have to be named, and the recognized names will have to be part of the prototype Policy object created by the implementation class. These could be called "policy arguments" to distinguish them from "policy attributes".
Resources have a similar notion with "account attributes", but the attributes are embodied in a User object that is passed in. Here we would probably just take a HashMap of name/values.
UPDATE: The interface has been extended to provide a generate() method. This method is responsible for generating an identifier that is consistent with the policy. The introduction of this, makes PolicyImplementation less extensible, its really only suitable for single string validation rules. We could consider separating id generation into another pluggable class, or splitting policy into two branches, one a simple string validator with generation, and another a more complex muli-valued rule.
Field Summary | |
static java.lang.Integer |
ALL_CHARS
Defines a value used to specify that all characters checked or generated should be of the a specific character type (e.g. |
static java.lang.String |
code_id
|
static java.lang.Integer |
NO_VALUE
Defines a value used to specify that no value has been set for char rules whose valid values includes '0'. |
protected static Trace |
trace
|
Constructor Summary | |
PolicyImplementation()
|
Method Summary | |
abstract void |
check(Policy policy,
java.lang.Object value,
java.util.Map params,
java.util.List pwdhistory,
java.lang.String owner)
similar to check, above. |
abstract void |
check(Policy policy,
java.lang.Object value,
java.lang.String owner)
Analyzes a single value for adherance to the policy. |
protected void |
checkPolicyArg(Policy p)
Checks to see if the supplied Policy object matches the implementation class. |
java.lang.Object |
generate(Policy policy)
Generates a object that would pass the check() method for this policy. |
java.lang.Object |
generate(Policy policy,
java.util.Map params,
java.util.List pwdHistory)
Generate an object that would pass the check() method for this policy. |
byte[] |
generateByteArray(Policy policy)
Generates a object that would pass the check() method for this policy. |
java.lang.Object |
getAllowedAttributeValues(java.lang.String name)
To help the GUI edit policy parameters, return possible values for an attribute. |
protected java.lang.Object |
getAttributeFromUser(Policy p,
WSUser user,
java.lang.String name,
java.lang.Object defaultValue)
Retrieves a policy attribute expected to be an object, stored on the user. |
protected boolean |
getBooleanAttribute(Policy p,
java.lang.String name,
boolean defaultValue)
Retrieves a policy attribute expected to be a boolean. |
LighthouseContext |
getContext()
|
protected int |
getIntAttribute(Policy p,
java.lang.String name,
int defaultValue)
Retrieves a policy attribute expected to be an integer. |
protected int |
getIntAttribute(Policy p,
java.lang.String name,
int defaultValue,
int len)
Retrieves a policy attribute whose value can be either an integer or "All". |
protected java.lang.Object |
getObjectAttribute(Policy p,
java.lang.String name,
java.lang.Object defaultValue)
Retrieves a policy attribute expected to be an object. |
abstract Policy |
getPrototype()
Returns the prototype instance of this policy. |
protected java.lang.String |
getStringAttribute(Policy p,
java.lang.String name,
java.lang.String defaultValue)
Retrieves a policy attribute expected to be a String If the attribute does not exist, or has no value, the "default" value is returned. |
protected java.util.List |
getStringListAttribute(Policy p,
java.lang.String name,
java.util.List defaultValues)
Retrieves a policy attribute expected to be a list of Strings If the attribute does not exist, or has no value, the "default" value is returned. |
protected java.lang.String |
getUserPropertyName(Policy p)
|
java.lang.Object |
getValue(Policy policy,
java.util.Map params,
java.lang.String owner)
similar to check, above. |
protected void |
setAttributeOnUser(Policy p,
WSUser user,
java.lang.String name,
java.lang.Object value)
Set the value of a policy attribute on a user. |
void |
setContext(LighthouseContext ctx)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String code_id
protected static final Trace trace
public static final java.lang.Integer ALL_CHARS
public static final java.lang.Integer NO_VALUE
Constructor Detail |
public PolicyImplementation()
Method Detail |
public abstract Policy getPrototype() throws WavesetException
WavesetException
public abstract void check(Policy policy, java.lang.Object value, java.lang.String owner) throws PolicyViolation, WavesetException
A policy object representing a particular "instance" of this policy implementation is passed in. This object supplies zero or more "policy attributes" which can be used to tailor the behavior of the policy.
PolicyViolation
- if the value violates the policy.
WavesetException
- if an internal error was encountered.public abstract void check(Policy policy, java.lang.Object value, java.util.Map params, java.util.List pwdhistory, java.lang.String owner) throws PolicyViolation, WavesetException
PolicyViolation
WavesetException
public java.lang.Object getValue(Policy policy, java.util.Map params, java.lang.String owner) throws WavesetException
WavesetException
- if an internal error was encountered.public java.lang.Object getAllowedAttributeValues(java.lang.String name)
public java.lang.Object generate(Policy policy) throws WavesetException
WavesetException
public java.lang.Object generate(Policy policy, java.util.Map params, java.util.List pwdHistory) throws WavesetException
WavesetException
public byte[] generateByteArray(Policy policy) throws WavesetException
WavesetException
protected void checkPolicyArg(Policy p) throws WavesetException
WavesetException
protected int getIntAttribute(Policy p, java.lang.String name, int defaultValue) throws WavesetException
WavesetException
protected boolean getBooleanAttribute(Policy p, java.lang.String name, boolean defaultValue) throws WavesetException
WavesetException
protected java.lang.Object getObjectAttribute(Policy p, java.lang.String name, java.lang.Object defaultValue) throws WavesetException
WavesetException
protected int getIntAttribute(Policy p, java.lang.String name, int defaultValue, int len) throws WavesetException
WavesetException
protected java.lang.String getStringAttribute(Policy p, java.lang.String name, java.lang.String defaultValue) throws WavesetException
WavesetException
protected java.util.List getStringListAttribute(Policy p, java.lang.String name, java.util.List defaultValues) throws WavesetException
WavesetException
protected java.lang.String getUserPropertyName(Policy p)
protected java.lang.Object getAttributeFromUser(Policy p, WSUser user, java.lang.String name, java.lang.Object defaultValue) throws WavesetException
WavesetException
protected void setAttributeOnUser(Policy p, WSUser user, java.lang.String name, java.lang.Object value) throws WavesetException
GenericObject
map returned by
getPolicyAttributes
.
Might want a variant of this that takes a WSAttribute for
symetry with getPolicyAttribute
?
WavesetException
public void setContext(LighthouseContext ctx)
public LighthouseContext getContext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |