Package DE_EPAGES::Presentation::Servlet::Permission
This servlet is the main dispatcher for all permission-based URL events. The application server function DE_EPAGES::WebInterface::API::ApplicationServer::run Chooses the actually used servlet package based on the configuration file $ENV{EPAGES_CONFIG}/Servlet.conf. Then it executes the methods new, init and handle on the servlet to process an incoming request.
Example |
# create a new servlet object my $Servlet = $Package->new; # initialize the servlet with parameters from the Servlet.conf section $Servlet->init( \%Parameters ) if $Handler->can( 'init' ); # create the respose from the request $Servlet->handle( $Request, $Response ); |
Functions
- action
- addBaseLineURL
- baseLineContentLocation
- checkDomain
- cookies
- cookiesAtPath
- cookiesEnabled
- createAnonymousUser
- createSecurityToken
- currencyID
- defaults
- doActions
- doChangeActions
- doViewAction
- environment
- form
- handle
- handleEncodingFormError
- handleError
- handleInvalidForm
- handleMonitorNotFound
- handleObjectNotFound
- handlePermissionDenied
- handleSiteIsClosed
- handleStoreNotFound
- handleWrongUrlParameter
- hasPermission
- historyUri
- init
- intSessionID
- isEditorMode
- isEditorNavElements
- languageID
- locale
- logUserFault
- logout
- monitor
- monitorThread
- new
- object
- params
- processContent
- processErrorContent
- processMonitorContent
- registerSession
- request
- response
- saveHistory
- serverVariables
- setCurrencyID
- setLanguageID
- setLocale
- testPermission
- user
- vars
- verifySecurityToken
- viewError
- viewInvalidURLError
- viewObject
- writeContentOutput
action
Returns the current action, else undef.
Syntax |
$Action = $Servlet->action; |
Return |
|
addBaseLineURL
adds base to response if necessary. if found head tag then the html tag base will be appended to the head tag, otherwise the obsolate Content-Base http header tag is added.
Syntax |
$Servlet->addBaseLineURL; |
baseLineContentLocation
Builds the base url. This url includes the path info. The path info is used to save cookies at the url if coolies are not enabled or never send before.
Syntax |
my $BaseLineContentLocation = $Servlet->baseLineContentLocation($UseSSL, $Object); |
Input |
|
Return |
|
checkDomain
Checks if the object is allowed to be requested via the $DomainName. The root object is always accessible. IP-Addresses and domain names not including a dot are always allowed. In addition, each object can be requested via the domain configured for it's site object or the domains configured as webserver host or webserver SSL host in the technical administration.
Syntax |
$IsValid = $Servlet->checkDomain( $Object, $DomainName ); if (!checkDomain($Object, 'www.epages.de')) { ... } |
Input |
|
Return |
|
cookies
Without parameter returns the function cookies which was served by the
request. On first run on servlet the form will be encoded.
With one parameter (name of cookie) the value of this cookie will be
returned.
With two parameter (name and value of cookie) the value of this cookie will be
set (includes send to client and set in vars).
Syntax |
$Cookies = $Servlet->cookies; $Cookie= $Servlet->cookies($Name); $Servlet->cookies($Name, $Value); $Servlet->cookies($Name, $Value, $hOptions); |
Input |
|
Return |
|
cookiesAtPath
Returns true if the session state is appended to the PATH_INFO part of the URL, for example if the browser does not accept cookies.
Syntax |
$CookiesAtPath = $Servlet->cookiesAtPath; |
Return |
|
cookiesEnabled
Returns true if the client browser accepts cookies. Checks if the HTTP Header "Cookie:" exists in the request.
Syntax |
$Enabled = $Servlet->cookiesEnabled; |
Return |
|
createAnonymousUser
Returns the new anonymous user. The user will be registered at $Site.
Syntax |
$User = $Servlet->createAnonymousUser($Site); |
Return |
|
createSecurityToken
Builds the security token or locale for url. The security Token starts always with 'sec'
Syntax |
my $TokenOrLocale = $Servlet->createSecurityToken; |
Return |
|
currencyID
Returns the currency id of the current request. The id is determined from the request parameters, user preferences, cookies or site preferences. If no currency was found, the default is used.
Syntax |
$CurrencyID = $Servlet->currencyID; $CurrencyID = $Servlet->currencyID($Reset); |
Input |
|
Return |
|
defaults
Without parameter returns defaults of Locale,Language,OutputEncoding.
With one parameter (name of defaults variable) the value of this defaults variable will be
returned.
Syntax |
$Defaults = $Servlet->defaults; $Value= $Servlet->defaults($Name); |
Input |
|
Return |
|
doActions
Executes all change actions and then executes the view action. Processing is terminated immediately at the first error. Calls handleError if an error occurs while processing an action.
Syntax |
$Servlet->doActions; |
doChangeActions
Executes all ChangeActions in the order of their appearance in the form or URL. Access permissions are checked before running the event handler.
Syntax |
$self->doChangeActions; |
doViewAction
Executes a ViewAction and fills the HTTP response using the template and TLE variables provided by the event handler function. Access permissions are checked before running the event handler.
Syntax |
$Servlet->doViewAction; |
environment
Without parameter returns environment(http header) which was served by
the request.
With one parameter (name of environment variable) the value of this
environment variable will be
returned.
Syntax |
$Environment = $Servlet->environment; $Value= $Servlet->environment($Name); |
Input |
|
Return |
|
form
Returns the form which was served by the request. On first run on servlet the form will be encoded.
Syntax |
$Form = $Servlet->form; |
Example |
my $Form = $Servlet->form; |
Return |
|
handle
Handles the request and produces a response. Connect to the database and executes ChangeActions and the ViewAction.
Syntax |
$Servlet->handle($Request, $Response); |
Input |
|
handleEncodingFormError
Handles the error "false encoding in url". This function sets the HTTP status 400 - "Bad Request" and displays an error message and logs a warning message containing QUERY_STRING and HTTP_REFERER.
Syntax |
$Servlet->handleEncodingFormError( $Error ); |
Input |
|
handleError
Handles an error. This function logs the error and then displays it using the viewError method.
Syntax |
$Servlet->handleError( $Error ); |
Input |
|
handleInvalidForm
calls doViewAction for the given error.
Syntax |
$self->handleInvalidForm($Error, $OnChangeAction, $ErrorAction, $ErrorObjectID); |
Input |
|
handleMonitorNotFound
Handles the error "FILE_NOT_FOUND" for not found monitor files. This function sets the HTTP status 404 - "Object not found" and displays an error message and logs a warning message containg QUERY_STRING and HTTP_REFERER.
Syntax |
$Servlet->handleMonitorNotFound( $Error ); |
Input |
|
handleObjectNotFound
Handles the error "Object not found" or "Path not found". This function sets the HTTP status 404 - "Object not found" and displays an error message and logs a warning message containg QUERY_STRING and HTTP_REFERER.
Syntax |
$Servlet->handleObjectNotFound( $Error ); |
Input |
|
handlePermissionDenied
Dispays the login form as a result of an unauthorized view action. Triggers the action ViewSimpleLoginForm and sets the followg TLE variables:
- PermissionDenied = 1
- PermissionDeniedText = $Error->shortMessage
Syntax |
$Servlet->handlePermissionDenied( $Error ); |
Input |
|
handleSiteIsClosed
Handles the error "Site is closed". This function sets the HTTP status 503 - "This Web site has been temporarily closed.".
Syntax |
$Servlet->handleSiteIsClosed( $Error ); |
Input |
|
handleStoreNotFound
This function sets the HTTP status 404 - "Not Found" and displays an error message and logs a warning message containing QUERY_STRING and HTTP_REFERER.
Syntax |
$Servlet->handleStoreNotFound( $Error ); |
Input |
|
handleWrongUrlParameter
Handles the error "url parameter has wrong value ". This function sets the HTTP status 400 - "Bad Request" and displays an error message and logs a warning message containing QUERY_STRING and HTTP_REFERER.
Syntax |
$Servlet->handleWrongUrlParameter( $Error ); |
Input |
|
hasPermission
Returns true if the current user has permission to execute an action. Loggs off the current user if the site is standalone and the user does not belong to this site.
Syntax |
$HasPermission = $Servlet->hasPermission( $Object, $ActionName); $HasPermission = $Servlet->hasPermission( $Object, $Action); |
Example |
unless( $Servlet->hasPermission( $Object, 'Delete' ) ) { print "Access denied"; } |
Input |
|
Return |
|
historyUri
returns uri for history.
Syntax |
$Servlet->historyUri; |
init
Copies $hParams->{'storename'} to to $self->vars( 'StoreName' ). Used by application server to add servlet vars from the servlet.conf configuration file.
Syntax |
$Servlet->init( $hParams ); |
Input |
|
intSessionID
Returns the internal session id of the current request. A form parameter with the name "SessionID" takes precedence over a cookie with the name "SessionID" (external sessionid).
Syntax |
$SessionID = $Servlet->intSessionID; |
Return |
|
isEditorMode
isbackoffice request (from form data)
Syntax |
$IsEditorMode = $Servlet->isEditorMode; |
Return |
|
isEditorNavElements
Returns whether the "IsEditorNavElements" parameter is set, indicating a preview frame with the SF in quick design / adv. design mode.
Syntax |
$isDesignEditor = $Servlet->isEditorNavElements; |
Return |
|
languageID
Returns the language id of the current request. The id is determined from language that corresponds to the current locale. See locale.
Syntax |
$LanguageID = $Servlet->languageID; |
Return |
|
locale
Returns the locale id of the current request. The id is determined from the request parameters, Cookie or object attribute. If no locales was found ,the default is used.
Syntax |
$LocaleID = $Servlet->locale; $LocaleID = $Servlet->locale($Reset); |
Input |
|
Return |
|
logUserFault
Logs a short message without stack trace using the log level "WARN" and log category 'USERFAULT::'.$Error->code
Syntax |
$Servlet->logUserFault( $Error ); |
logout
Invalidates the current session of the logged-on user. Deletes the session from the database and clears the cookies SessionID and UserGUID.
Syntax |
$Servlet->logout; |
monitor
Returns the monitor object.
Syntax |
$Monitor = $Servlet->monitor; |
Return |
|
monitorThread
Returns the monitor thread of the servlet.
Syntax |
$MonitorThread = $Servlet->monitorThread; |
Return |
|
new
Create a new servlet, set defaults on servlet like Locale,Language, OutputEncodinfg.
Syntax |
$Servlet = new DE_EPAGES::Presentation::Servlet::Permission; |
Example |
my $PermissionServlet = new DE_EPAGES::Presentation::Servlet::Permission; |
Return |
|
object
Returns the object on which the current action operates.
Syntax |
$Object = $Servlet->object; |
Return |
|
params
This function gives an central access to all parameter of the request.
No matter it comes as cookie, parameter, form field or set in set meantime
with vars.
Without parameter returns the function all parameter which was served by the
request and set via the request invars.
With one parameter (name of variable) the value will be returned.
With two parameter (name and value of variable) the value will be set
(with function vars).
Syntax |
$Params = $Servlet->params; $Value = $Servlet->params($Name); $Servlet->params($Name, $Value); |
Input |
|
Return |
|
processContent
process template and var hash to response string
Syntax |
$Content = $Servlet->processContent; |
Return |
|
processErrorContent
Builds an error message using the SimpleError template in English.
Syntax |
$Servlet->processErrorContent( $Error ); |
Input |
|
processMonitorContent
Creates the content of the default monitor page.
Syntax |
$Servlet->processMonitorContent($FileName, $hVars); |
Input |
|
registerSession
creates a new session id and save this as cookie. Applies the locale and currency preferences of the user ($User).
Syntax |
$IntSessionID = $Servlet->registerSession($User, $PerCookie); |
Input |
|
Return |
|
request
Return the assigned request (created on start of $Servlet->handle).
Syntax |
$Request = $Servlet->request; |
Example |
my $Request = $Servlet->request; |
Return |
|
response
Return the assigned response (created on start of $Servlet->handle).
Syntax |
$Response = $Servlet->response; |
Example |
my $Response = $Servlet->response; |
Return |
|
saveHistory
Adds the URI and page title of the current request to the session history in the database. The URI is returned by historyUri. The page title is composed from the action name and $self->params('Title') or object name.
Syntax |
$Servlet->saveHistory; |
serverVariables
Without parameter returns the function cookies which was served by the
request. On first run on servlet the form will be encoded.
With one parameter (name of server variable) the value of this key will be
returned.
Syntax |
$ServerVariables = $Servlet->serverVariables; $ServerVariable = $Servlet->serverVariables($Name); |
Input |
|
Return |
|
setCurrencyID
Sets the currency for the current user. Creates a new anonymous user if there is currently no user.
Syntax |
$Servlet->setCurrencyID($CurrencyID); |
Example |
$Servlet->setCurrencyID('USD'); |
Input |
|
setLanguageID
obsolete. Use $Servlet->setLocale.
setLocale
Sets the locale for the current request by modifying the URL of the next pages. If the session is associated with a user and $SetUser is true, then the user default locale is also changed.
Syntax |
$Servlet->setLocale($LocaleID); $Servlet->setLocale($LocaleID, $SetUser); |
Example |
$Servlet->setLocale($LocaleID); $Servlet->setLocale($LocaleID, 0); |
Input |
|
testPermission
Verifies if the current user has permission to execute a selected Event. Throws an error if permission is denied.
Syntax |
$Servlet->testPermission( $Object, $Action); $Servlet->testPermission( $Object, $ActionName); |
Example |
eval { $Servlet->testPermission( $Object, 'Delete' ); } if( ExistsError() && GetError()->code eq 'PermissionDenied' ) { print "Access denied"; } |
Input |
|
user
Returns the user from the current session. The user is determined from the SessionID parameter.
Syntax |
$user = $Servlet->user; |
Return |
|
vars
Without parameter returns all set variables.
With one parameter (name of variable) the value of this variable will be
returned.
With two parameter (name and value of variable) the value of this variable will be
set.
Syntax |
$hVars = $Servlet->vars; $Value= $Servlet->vars($Name); $Servlet->vars($Name, $Value); |
Example |
$Servlet->vars('OutputEncoding', 'ISO-8859-1'); |
Input |
|
Return |
|
verifySecurityToken
Reads security token or locale from url. No error if token correct or no user logged in.
Syntax |
$Servlet->verifySecurityToken; |
viewError
Displayse an error page, which is processed by processErrorContent.
Syntax |
$Servlet->viewError( $Error ); |
Input |
|
viewInvalidURLError
Displayse an invalid url error, which is processed by processErrorContent.
Syntax |
$Servlet->viewInvalidURLError( $Error ); |
Input |
|
viewObject
Returns the Object for the ViewAction.
Syntax |
my $Object = $Servlet->viewObject; |
writeContentOutput
Fills the HTTP response with the given content in the correct encoding. Hint: you can set the output encoding and content-type via the servlet parameters, eg: $Servlet->vars('OutputEncoding', 'utf-8'); $Servlet->vars('ContentType', 'text/x-json');
Syntax |
$Servlet->writeContentOutput($Content); |
Input |
|