|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.sandev.basics.util.AuthFilterBase
public abstract class AuthFilterBase
A base class for AuthFilter implementations with some useful utility methods. This breaks out the standard message class, instance, field and value access out by message type rather than verb type to make things easier to maintain when fine grained access control at the field level is needed.
To extend from this base, override the required abstract methods and then write an access method and optional query restriction method for each authorized messaging class defined in your application.
| Field Summary | |
|---|---|
static int |
ACCTYPE_CLASS
message class access |
static int |
ACCTYPE_FIELD
field access |
static int |
ACCTYPE_FIELDVAL
field value access |
static int |
ACCTYPE_INSTANCE
message instance access |
| Fields inherited from interface org.sandev.basics.util.AuthFilter |
|---|
AUTH_ARRAYACCESS, AUTH_ARRAYADD, AUTH_ARRAYDELETE, AUTH_ARRAYMOVE, AUTH_ARRAYNEW, AUTH_NOACCESS, AUTH_READONLY, AUTH_READONLYNODISP, AUTH_UNRESTRICTED, AUTH_UNRESTRICTEDNODISP, AUTH_UNRESTRICTEDREADONLY, AUTH_VALHIDDEN |
| Constructor Summary | |
|---|---|
AuthFilterBase()
|
|
| Method Summary | |
|---|---|
protected int |
accAggregateUpdate(int accType,
AuthUser user,
java.lang.String msgClass,
SandMessage msg,
java.lang.String fieldName)
Return the level of authorization for AggregateUpdate access. |
static java.lang.String |
accessType(int access)
Given an AuthFilter access constant, return a debug print name. |
protected SandAttrVal[] |
addMatch(SandAttrVal[] matches,
SandAttrVal newmatch)
Add this SandAttrVal to the existing array and return the new array. |
protected int |
checkAccess(int accType,
AuthUser user,
java.lang.String msgClass,
SandMessage msg,
java.lang.String fieldName)
Given the type of checking and other message information return the level of authorization. |
protected abstract void |
debug(java.lang.String text)
Log trace level and general information about what the AuthFilter is doing. |
protected void |
debugDumpMatches(java.lang.String prefix,
SandAttrVal[] matches)
Dump out the given matches using the debug dump method. |
protected int |
generatedFieldAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
Return the authorization level for the given generated field within the given message for the given user. |
java.lang.String |
getBaseMsgClass(java.lang.String msgClass)
Given the name of a message, return the short struct message name. |
java.lang.String |
getMatchValue(SandAttrVal[] matches,
java.lang.String attr)
Return the value specified for the give attr from the given matches, or null if not found. |
protected SandAttrVal[] |
getRestrictions(AuthUser user,
java.lang.String msgClass,
SandAttrVal[] givenMatches)
Given the user, the class name of a message, and the existing match restrictions, return the additional match restrictions to be added to the query. |
protected long[] |
getSpecifiedUniqueIDs(SandAttrVal[] matches)
Return an array of the uniqueID values specified. |
protected java.lang.String |
getUserDump(AuthUser user)
Return a text identification of this user for debug logging. |
boolean |
hasMatch(SandAttrVal[] matches,
java.lang.String attr,
java.lang.String val)
Return true if the given matches contains the given attrval, false otherwise. |
boolean |
hasSingleValueMatch(SandAttrVal[] matches,
java.lang.String attr)
Return true if the given matches contains a single value with no operator for the given attr. |
boolean |
isAdminRestrictedClass(java.lang.String className)
If a class is restricted even for an admin user, then return true for that class name to authorize manually. |
protected abstract boolean |
isAdminUser(long id)
Return true if the given id is the uniqueID of an admin user. |
boolean |
isClassNameMatch(java.lang.String testName,
java.lang.String matchName)
Return true if the testname specified is a direct match or common derived form for the matchname. |
boolean |
isCompletelyUnrestrictedClass(java.lang.String className)
Return true if the given class is completely unrestricted in terms of authorization. |
protected boolean |
isGeneratedField(java.lang.String fieldName)
Return true if the given field name is a framework generated field, false otherwise. |
protected abstract boolean |
isLoginMessageClass(java.lang.String className)
Return true if the given class name is an AuthUser class that is used for login purposes. |
protected abstract boolean |
isSingletonInstance(SandUpdateMessage sum)
Return true if the given message is an update of a singleton class that should not be deleted or have additional instances created, even by an admin. |
SandAttrVal[] |
matchRestrictions(AuthUser user,
java.lang.String className,
SandAttrVal[] savs)
Return match criteria necessary to bound queries of this message class so that users can only access data they are allowed to see. |
int |
messageClassAccess(AuthUser user,
java.lang.String className)
Determine what users have access to what messages. |
int |
messageFieldAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
Restrict access to some fields of the message data based on user ownership. |
int |
messageFieldValueAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
Always returns AUTH_UNRESTRICTED. |
int |
messageInstanceAccess(AuthUser user,
SandMessage msg)
Determine if this user is allowed to view this instance of this message. |
java.lang.String |
shortenClassName(java.lang.String classname)
Strip any preceding qualifications to return the short class name. |
protected long |
specifiedUniqueID(SandAttrVal[] matches)
Return the uniqueID specified in the matches, or zero if no uniqueID is found. |
int |
tokenAccess(AuthUser user,
java.lang.String token)
The names of any screens, actions, or other tokens that should be hidden from the user. |
protected boolean |
uniqueIDSpecified(SandAttrVal[] matches)
Return true if the uniqueID is specified as one of the match criteria, false otherwise. |
SandAttrVal[] |
verifyMatch(SandAttrVal[] newMatches,
SandAttrVal[] oldMatches,
java.lang.String attr,
java.lang.String val)
Walk the newMatches and the oldMatches checking for the given attr. |
protected abstract void |
warn(java.lang.String text)
Log the given problem text for development reference. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ACCTYPE_CLASS
public static final int ACCTYPE_INSTANCE
public static final int ACCTYPE_FIELD
public static final int ACCTYPE_FIELDVAL
| Constructor Detail |
|---|
public AuthFilterBase()
| Method Detail |
|---|
protected abstract boolean isAdminUser(long id)
protected abstract boolean isLoginMessageClass(java.lang.String className)
protected abstract boolean isSingletonInstance(SandUpdateMessage sum)
protected abstract void debug(java.lang.String text)
protected abstract void warn(java.lang.String text)
public int tokenAccess(AuthUser user,
java.lang.String token)
throws SandException
tokenAccess in interface AuthFilterSandException
protected int generatedFieldAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
Persistency fields are maintained by the persistence processing and should never be modified directly by any user. Runtime and transient fields used for caching and message transmission are generally not part of editing a form.
public boolean isCompletelyUnrestrictedClass(java.lang.String className)
A cache action is triggered in response to an update, and uses the SandTransmitAuthID of the update that caused it for transmission across an authorization boundary. The assumption is that cache information is not available outside the system, so there is no reason to restrict access to it.
public boolean isAdminRestrictedClass(java.lang.String className)
public int messageClassAccess(AuthUser user,
java.lang.String className)
throws SandException
messageClassAccess in interface AuthFilterSandException
public int messageInstanceAccess(AuthUser user,
SandMessage msg)
throws SandException
While this method will be called to filter a collection of instances, we don't want to be in a situation where we are pulling instances out of a collection because it has the potential for causing paging problems in the UI. Restricting collections is best done through matchRestrictions.
messageInstanceAccess in interface AuthFilterSandException
public int messageFieldAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
throws SandException
messageFieldAccess in interface AuthFilterSandException
public int messageFieldValueAccess(AuthUser user,
SandMessage msg,
java.lang.String fieldName)
throws SandException
messageFieldValueAccess in interface AuthFilterSandException
public SandAttrVal[] matchRestrictions(AuthUser user,
java.lang.String className,
SandAttrVal[] savs)
throws SandException
matchRestrictions in interface AuthFilterSandException
protected int checkAccess(int accType,
AuthUser user,
java.lang.String msgClass,
SandMessage msg,
java.lang.String fieldName)
throws SandException
SandException
protected int accAggregateUpdate(int accType,
AuthUser user,
java.lang.String msgClass,
SandMessage msg,
java.lang.String fieldName)
throws SandException
SandException
protected SandAttrVal[] getRestrictions(AuthUser user,
java.lang.String msgClass,
SandAttrVal[] givenMatches)
throws SandException
SandExceptionpublic java.lang.String shortenClassName(java.lang.String classname)
public static java.lang.String accessType(int access)
protected boolean isGeneratedField(java.lang.String fieldName)
protected java.lang.String getUserDump(AuthUser user)
protected SandAttrVal[] addMatch(SandAttrVal[] matches,
SandAttrVal newmatch)
protected void debugDumpMatches(java.lang.String prefix,
SandAttrVal[] matches)
protected boolean uniqueIDSpecified(SandAttrVal[] matches)
protected long[] getSpecifiedUniqueIDs(SandAttrVal[] matches)
protected long specifiedUniqueID(SandAttrVal[] matches)
public java.lang.String getBaseMsgClass(java.lang.String msgClass)
public boolean isClassNameMatch(java.lang.String testName,
java.lang.String matchName)
public SandAttrVal[] verifyMatch(SandAttrVal[] newMatches,
SandAttrVal[] oldMatches,
java.lang.String attr,
java.lang.String val)
public boolean hasMatch(SandAttrVal[] matches,
java.lang.String attr,
java.lang.String val)
public boolean hasSingleValueMatch(SandAttrVal[] matches,
java.lang.String attr)
public java.lang.String getMatchValue(SandAttrVal[] matches,
java.lang.String attr)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||