public class HasFunction extends DynamoServlet implements atg.userdirectory.droplet.Constants
Here are some examples of using this droplet...
This is an example of using the droplet to see if the current
user has a relative role, with a function name of admin.
<droplet bean="/atg/userdirectory/HasFunction">
<param name="userid"
value="bean:/atg/userprofiling/Profile.id"/>
<param name="function" value="admin"/>
<oparam name="true">
Have the admin function
</oparam>
<oparam name="false">
Do not have the admin function
</oparam>
</droplet>
This example will do the same as the above example except that it
will additionally ensure that the the relativeRole is relative to
an organization with an id of org3004
<droplet bean="/atg/userdirectory/HasFunction">
<param name="userid"
value="bean:/atg/userprofiling/Profile.id"/>
<param name="function" value="admin"/>
<param name="organizationId" value="org3004"/>
<oparam name="true">
Have the admin function
</oparam>
<oparam name="false">
Do not have the admin function
</oparam>
</droplet>
UserDirectory
,
RelativeRole
,
OrganizationalEntity
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION |
static ParameterName |
FALSE |
static ParameterName |
FUNCTION |
static ParameterName |
ORGANIZATION_ID |
static ParameterName |
TRUE |
static ParameterName |
USER_ID |
mAllowCleanupRequest, mParameters
SERVLET_INFO_KEY
SERVICE_INFO_KEY
EMPTY, ERROR, INVALID_OPTIONAL_PARAM, MISSING_REQUIRED_PARAM, NO_ORGANIZATION, NO_USER, OUTPUT
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
HasFunction() |
Modifier and Type | Method and Description |
---|---|
UserDirectory |
getUserDirectory()
Gets the userDirectory property
|
protected boolean |
isMissingParameters(java.lang.String pUserId,
java.lang.String pFunctionName,
java.lang.String pOrganization)
This method will determine if there are any missing parameters
passed to this droplet.
|
protected boolean |
isUserHasFunction(java.util.Collection pRoles,
java.lang.String pFunctionName,
Organization pOrganization)
This method determines if the user has the function specified.
|
void |
service(DynamoHttpServletRequest pRequest,
DynamoHttpServletResponse pResponse)
The service method will perform the work of this droplet.
|
void |
setUserDirectory(UserDirectory pUserDirectory)
Sets the userDirectory property
|
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, init, service, service, setParameter
destroy, getServletConfig, getServletInfo, setServletInfo
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
public static java.lang.String CLASS_VERSION
public static final ParameterName USER_ID
public static final ParameterName FUNCTION
public static final ParameterName ORGANIZATION_ID
public static final ParameterName TRUE
public static final ParameterName FALSE
public void setUserDirectory(UserDirectory pUserDirectory)
pUserDirectory
- the userdirectory to perform onpublic UserDirectory getUserDirectory()
protected boolean isUserHasFunction(java.util.Collection pRoles, java.lang.String pFunctionName, Organization pOrganization)
pOrganization
parameter is optional. If it
is specified, then this method will only return true
if the user has the function relative to the supplied organization.
This method works by iterating over the collection of roles
passed in via the pRoles
parameter. If any of the
roles are atg.userdirectory.RelativeRole
then the function name is extracted from the role. If the function
name for the role matches the function name supplied by the
RelativeRoles
pFunctionName
parameter, then this will method will
return true
.
pRoles
- collection of roles relative to a particular principalpFunctionName
- function name to search for in the role listpOrganization
- optional parameter. If specified, this method
will only return true if there is a relative role whose function equals
the specified function name via pFunctionName
parameter
AND that function is found on a relative role that is relative to
pOrganization
public void service(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse) throws javax.servlet.ServletException, java.io.IOException
isMissingParameters()
method.
Next, it will extract the user and organization by their
primaryKey from the UserDirectory
property that is configured. If the user
can not be extracted, an error condition is triggered. If the
page author supplied an organization id and the organization can
not be extracted, then an error condition is triggered.
Finally, the
method will be called to determine if the
user has the specified function associated with them. isUserHasFunction
service
in class DynamoServlet
pRequest
- a DynamoHttpServletRequest
valuepResponse
- a DynamoHttpServletResponse
valuejavax.servlet.ServletException
- if an error occursjava.io.IOException
- if an error occursprotected boolean isMissingParameters(java.lang.String pUserId, java.lang.String pFunctionName, java.lang.String pOrganization)
pUserId
- a String
valuepFunctionName
- a String
valuepOrganization
- a String
valueboolean
value