|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectno.feide.moria.servlet.RequestUtil
public final class RequestUtil
This class is a toolkit for the servlets. Its main functionality is to retrieve resource bundles.
Field Summary | |
---|---|
static java.lang.String |
ATTR_BASE_URL
Base URL attribute in request object. |
static java.lang.String |
ATTR_BUNDLE
Attribute in request object: Language bundle. |
static java.lang.String |
ATTR_CLIENT_NAME
Attribute in request object: Name of client/service. |
static java.lang.String |
ATTR_CLIENT_URL
Attribute in request object: Link to associate with service name. |
static java.lang.String |
ATTR_ERROR_TYPE
Attribute in request object: Error type. |
static java.lang.String |
ATTR_LANGUAGES
Attribute in request object: Available languages. |
static java.lang.String |
ATTR_ORGANIZATIONS
Attribute in request object: Available organizations. |
static java.lang.String |
ATTR_REQUESTED_ATTRIBUTES
Attribute in request object: Requested attributes. |
static java.lang.String |
ATTR_SEC_LEVEL
Attribute in request object: Security level. |
static java.lang.String |
ATTR_SELECTED_DENYSSO
Attribute in request object: Denial of SSO. |
static java.lang.String |
ATTR_SELECTED_LANG
Attribute in request object: Preselected lanugage. |
static java.lang.String |
ATTR_SELECTED_ORG
Attribute in request object: Preselected organization. |
static java.lang.String |
BUNDLE_ERROR
Bundle for the error page. |
static java.lang.String |
BUNDLE_FAQ
Bundle for the faq page. |
static java.lang.String |
BUNDLE_INFOABOUT
Bundle for the information page about the information servlet. |
static java.lang.String |
BUNDLE_INFORMATIONSERVLET
Bundle for the Information servlet's attribute descriptions. |
static java.lang.String |
BUNDLE_INFOWELCOME
Bundle for the Welcome page for the Information Service. |
static java.lang.String |
BUNDLE_LOGIN
The name of the resource bundle for the login page. |
static java.lang.String |
BUNDLE_STATISTICSSERVLET
Bundle for the Statistics page. |
static java.lang.String |
BUNDLE_STATUSSERVLET
Bundle for the status servlet. |
static java.lang.String |
CONFIG_DISPLAY_NAME
From Authorization config: Service name. |
static java.lang.String |
CONFIG_HOME
From Authorization config Home organization of service. |
static java.lang.String |
CONFIG_LANG
Name of property from authorization module giving the default language for a given service. |
static java.lang.String |
CONFIG_SERVICE_PRINCIPAL
From Authorization configuration; service principal. |
static java.lang.String |
CONFIG_URL
From Authorization config: Service URL. |
static java.lang.String |
ERROR_AUTHENTICATION_FAILED
Error type: Authentication failed. |
static java.lang.String |
ERROR_AUTHORIZATION_FAILED
Error type: Authorization failed. |
static java.lang.String |
ERROR_DIRECTORY_DOWN
Error type: The directory is down. |
static java.lang.String |
ERROR_INVALID_ORG
Error type: Invalid organization selected. |
static java.lang.String |
ERROR_MORIA_DOWN
Error type: Moria is unavailable. |
static java.lang.String |
ERROR_NO_CREDENTIALS
Error type: User must supply username and password. |
static java.lang.String |
ERROR_NO_ORG
Error type: No organization selected. |
static java.lang.String |
ERROR_UNKNOWN_TICKET
Error type: Unknown ticket. |
static java.lang.String |
FAQ_LINK
Link to faq, shown on the login page. |
(package private) static no.feide.moria.log.MessageLogger |
log
Used for logging. |
static java.lang.String |
PARAM_DENYSSO
Parameter in request object: Deny SSO. |
static java.lang.String |
PARAM_LANG
Language URL parameter, used when overriding current language settings. |
static java.lang.String |
PARAM_OLD_STATISTICS
Attribute URL parameter, used to show statistics from the previous year. |
static java.lang.String |
PARAM_ORG
Organization URL parameter, used when overriding default organization in the URL redirecting a user from a service to Moria. |
static java.lang.String |
PARAM_PASSWORD
Parameter in request object: Password. |
static java.lang.String |
PARAM_SHOW_ATTRS
Attribute URL parameter, used when attributes are shown on the login page. |
static java.lang.String |
PARAM_USERNAME
Parameter in request object: Username. |
private static java.lang.String |
PATH_PREFIX
Prefix for all web module properties. |
static java.lang.String |
PIC_LINK
Link to pictures from the information service. |
static java.lang.String |
PROP_BACKENDSTATUS_IGNORE
Configuration property for the StatisticsServlet's ignored services |
static java.lang.String |
PROP_BACKENDSTATUS_STATISTICS_XML
Configuration property for the StatusServlet statistics.xml file path. |
static java.lang.String |
PROP_BACKENDSTATUS_STATISTICS2_BASENAME_XML
Configuration property for the StatusServlet statistics2 basename file path. |
static java.lang.String |
PROP_BACKENDSTATUS_STATISTICS2_XML
Configuration property for the StatusServlet statistics2.xml file path. |
static java.lang.String |
PROP_BACKENDSTATUS_STATUS_XML
Configuration property for the StatusServlet status.xml file path. |
static java.lang.String |
PROP_COMMON
Configuration property sub-string giving the abbreviations and names for all available languages. |
static java.lang.String |
PROP_CONFIG
Property name for web module configuration. |
static java.lang.String |
PROP_COOKIE_DENYSSO
Configuration property giving the name of the cookie used to deny SSO (when using Moria on public computers, for example). |
static java.lang.String |
PROP_COOKIE_DENYSSO_TTL
Configuration property giving the lifetime, in hours, for the cookie used to deny SSO (named by PROP_COOKIE_DENYSSO ). |
static java.lang.String |
PROP_COOKIE_LANG
Configuration property giving the name of the cookie used to set user's desired language. |
static java.lang.String |
PROP_COOKIE_LANG_TTL
Configuration property giving the lifetime, in hours, for the cookie used to set user's desired language. |
static java.lang.String |
PROP_COOKIE_ORG
Configuration property giving the name of the cookie used to remember the user's previously selected organization. |
static java.lang.String |
PROP_COOKIE_ORG_TTL
Configuration property giving the lifetime, in hours, for the cookie used to remember the user's previously selected organization. |
static java.lang.String |
PROP_COOKIE_SSO
Configuration property giving the name of the cookie used to carry SSO sessions (that is, a Moria ticket ID belonging to a SSO session). |
static java.lang.String |
PROP_COOKIE_SSO_TTL
Configuration property giving the lifetime, in hours, for the cookie used to carry SSO sessions (named by PROP_COOKIE_SSO ). |
static java.lang.String |
PROP_FAQ_OWNER
Organization name of the Moria owner, as shown on the FAQ page. |
static java.lang.String |
PROP_FAQ_STATUS
URL to the Status servlet, as shown on the FAQ page. |
static java.lang.String |
PROP_INFORMATION_DESCRIPTIONS
Configuration property for the Information service's attribute description XML file. |
static java.lang.String |
PROP_INFORMATION_URL_PREFIX
Configuration property giving the URL of the information servlet. |
static java.lang.String |
PROP_LANGUAGE
Property name for Language. |
static java.lang.String |
PROP_LOGIN_DEFAULT_LANGUAGE
Configuration property giving the default Moria language, to be used if no other preferences (user or service) are available. |
static java.lang.String |
PROP_LOGIN_TICKET_PARAM
Configuration property giving the name of the URL parameter containing the Moria ticket ID. |
static java.lang.String |
PROP_LOGIN_URL_PREFIX
Configuration property giving the URL of the login servlet. |
static java.lang.String |
PROP_LOGOUT_URL_PARAM
Property name for Logout URL. |
static java.lang.String |
PROP_ORG
Property name for Organization. |
static java.lang.String |
PROP_STATISTICS_URL
URL to the Statistics servlet, used for language selection. |
static java.lang.String |
RESOURCE_DATE
TODO: Add JavaDoc. |
static java.lang.String |
RESOURCE_LINK
TODO: Add JavaDoc. |
static java.lang.String |
RESOURCE_MAIL
TODO: Add JavaDoc. |
Constructor Summary | |
---|---|
private |
RequestUtil()
Default private constructor. |
Method Summary | |
---|---|
static javax.servlet.http.Cookie |
createCookie(java.lang.String cookieName,
java.lang.String cookieValue,
int validHours)
Creates a cookie. |
static java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
java.lang.String requestParamLang,
java.lang.String langFromCookie,
java.lang.String serviceLang,
java.lang.String browserLang,
java.lang.String moriaLang)
Generates a resource bundle. |
(package private) static java.util.Properties |
getConfig(javax.servlet.ServletContext context)
Get the config from the context. |
static java.lang.String |
getCookieValue(java.lang.String cookieName,
javax.servlet.http.Cookie[] cookies)
Returns a requested cookie value from the HTTP request. |
static java.lang.String |
insertLink(java.lang.String token,
java.lang.String data,
java.lang.String name,
java.lang.String url)
Replaces a given token with hyperlinks. |
private static java.util.ResourceBundle |
locateBundle(java.lang.String bundleName,
java.lang.String lang)
Locates a bundle in a given language. |
(package private) static java.util.TreeMap |
parseConfig(java.util.Properties config,
java.lang.String element,
java.lang.String language)
Reads institution names from the servlet configuration and generates a TreeMap with the result, using the correct language. |
(package private) static java.lang.String[] |
sortedAcceptLang(java.lang.String acceptLang)
Parses an Accept-Language header sent from a browser. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
static no.feide.moria.log.MessageLogger log
private static final java.lang.String PATH_PREFIX
"no.feide.moria.web."
.
public static final java.lang.String PROP_CONFIG
PATH_PREFIX + "config"
.
public static final java.lang.String PROP_LOGIN_TICKET_PARAM
PATH_PREFIX + "login.ticket_param"
.
public static final java.lang.String PROP_ORG
public static final java.lang.String PROP_LOGIN_DEFAULT_LANGUAGE
PATH_PREFIX + "login.default_language"
.
public static final java.lang.String PROP_LANGUAGE
public static final java.lang.String PROP_LOGIN_URL_PREFIX
PATH_PREFIX + "login.url_prefix"
.
public static final java.lang.String PROP_INFORMATION_URL_PREFIX
PATH_PREFIX + "information.url_prefix"
.
public static final java.lang.String PROP_COMMON
PROP_LANGUAGE + "_" + PROP_COMMON
.EN:English
, that is, a two-letter language abbreviation
and a ':' character followed by its display name. "common"
.
public static final java.lang.String PROP_COOKIE_ORG
PATH_PREFIX + "cookie.org.name"
.
public static final java.lang.String PROP_COOKIE_ORG_TTL
PATH_PREFIX + "cookie.org.ttl"
.
PROP_COOKIE_ORG
,
Constant Field Valuespublic static final java.lang.String PROP_COOKIE_LANG
PATH_PREFIX + "cookie.lang.name"
.
public static final java.lang.String PROP_COOKIE_LANG_TTL
PATH_PREFIX + "cookie.lang.ttl"
.
public static final java.lang.String PROP_COOKIE_SSO
PATH_PREFIX + "cookie.sso.name"
.
public static final java.lang.String PROP_COOKIE_SSO_TTL
PROP_COOKIE_SSO
).
This property is required.PATH_PREFIX + "cookie.sso.ttl"
.
public static final java.lang.String PROP_COOKIE_DENYSSO
PATH_PREFIX + "cookie.denysso.name"
.
public static final java.lang.String PROP_COOKIE_DENYSSO_TTL
PROP_COOKIE_DENYSSO
).
This property is requiredPATH_PREFIX + "cookie.denysso.ttl"
.
PROP_COOKIE_DENYSSO
,
Constant Field Valuespublic static final java.lang.String PROP_LOGOUT_URL_PARAM
public static final java.lang.String BUNDLE_LOGIN
"login"
.
public static final java.lang.String BUNDLE_INFOWELCOME
public static final java.lang.String BUNDLE_STATISTICSSERVLET
public static final java.lang.String PROP_INFORMATION_DESCRIPTIONS
public static final java.lang.String PROP_BACKENDSTATUS_STATUS_XML
public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS_XML
public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS2_BASENAME_XML
public static final java.lang.String PROP_BACKENDSTATUS_STATISTICS2_XML
public static final java.lang.String PROP_BACKENDSTATUS_IGNORE
public static final java.lang.String BUNDLE_INFORMATIONSERVLET
public static final java.lang.String BUNDLE_INFOABOUT
public static final java.lang.String BUNDLE_STATUSSERVLET
public static final java.lang.String BUNDLE_FAQ
public static final java.lang.String BUNDLE_ERROR
public static final java.lang.String FAQ_LINK
public static final java.lang.String PROP_FAQ_STATUS
PATH_PREFIX + "faq.status"
.
public static final java.lang.String PROP_STATISTICS_URL
public static final java.lang.String PROP_FAQ_OWNER
PATH_PREFIX + "faq.owner"
.
public static final java.lang.String PIC_LINK
public static final java.lang.String RESOURCE_MAIL
public static final java.lang.String RESOURCE_DATE
public static final java.lang.String RESOURCE_LINK
public static final java.lang.String CONFIG_LANG
"language"
.
public static final java.lang.String CONFIG_HOME
public static final java.lang.String CONFIG_DISPLAY_NAME
public static final java.lang.String CONFIG_SERVICE_PRINCIPAL
public static final java.lang.String CONFIG_URL
public static final java.lang.String PARAM_USERNAME
public static final java.lang.String PARAM_PASSWORD
public static final java.lang.String PARAM_ORG
"org"
.
public static final java.lang.String PARAM_LANG
"language"
.
public static final java.lang.String PARAM_SHOW_ATTRS
public static final java.lang.String PARAM_OLD_STATISTICS
public static final java.lang.String PARAM_DENYSSO
public static final java.lang.String ATTR_BASE_URL
"baseURL"
.
public static final java.lang.String ATTR_SEC_LEVEL
public static final java.lang.String ATTR_ERROR_TYPE
public static final java.lang.String ATTR_LANGUAGES
public static final java.lang.String ATTR_ORGANIZATIONS
public static final java.lang.String ATTR_SELECTED_ORG
public static final java.lang.String ATTR_SELECTED_DENYSSO
public static final java.lang.String ATTR_SELECTED_LANG
public static final java.lang.String ATTR_CLIENT_NAME
public static final java.lang.String ATTR_CLIENT_URL
public static final java.lang.String ATTR_BUNDLE
public static final java.lang.String ATTR_REQUESTED_ATTRIBUTES
public static final java.lang.String ERROR_NO_ORG
public static final java.lang.String ERROR_INVALID_ORG
public static final java.lang.String ERROR_AUTHENTICATION_FAILED
public static final java.lang.String ERROR_AUTHORIZATION_FAILED
public static final java.lang.String ERROR_UNKNOWN_TICKET
public static final java.lang.String ERROR_DIRECTORY_DOWN
public static final java.lang.String ERROR_MORIA_DOWN
public static final java.lang.String ERROR_NO_CREDENTIALS
Constructor Detail |
---|
private RequestUtil()
Method Detail |
---|
public static java.util.ResourceBundle getBundle(java.lang.String bundleName, java.lang.String requestParamLang, java.lang.String langFromCookie, java.lang.String serviceLang, java.lang.String browserLang, java.lang.String moriaLang)
requestParamLang
)
langFromCookie
)
serviceLang
)
browserLang
)
moriaLang
)
bundleName
- Name of the resource bundle to retrieve. Cannot be
null
.requestParamLang
- Language specified from URL parameter. Can be
null
.langFromCookie
- Language specified from user's cookie. Can be
null
.serviceLang
- Default language as specified by configuration for the
service. Can be null
.browserLang
- Language as requested by the users browser. Can be
null
.moriaLang
- Default language for Moria. Cannot be null
.
java.lang.IllegalArgumentException
- If bundleName
or moriaLang
is
null
or an empty string.
java.util.MissingResourceException
- If the resource bundle cannot be found.private static java.util.ResourceBundle locateBundle(java.lang.String bundleName, java.lang.String lang)
bundleName
- Name of the bundle, cannot be null or "".lang
- The bundle's langauge.
java.lang.IllegalArgumentException
- If bundleName
or lang
is
null
or an empty string.public static java.lang.String getCookieValue(java.lang.String cookieName, javax.servlet.http.Cookie[] cookies)
cookieName
- Name of the cookie.cookies
- The cookies from the HTTP request.
java.lang.IllegalArgumentException
- If cookieName
is null or an empty string.public static javax.servlet.http.Cookie createCookie(java.lang.String cookieName, java.lang.String cookieValue, int validHours)
cookieName
- Name of the cookie. Cannot be null
.cookieValue
- Value to set in cookie. Cannot be null
.validHours
- Number of hours before the cookie expires. Must be 0 or
greater.
java.lang.IllegalArgumentException
- If cookieName
or cookieValue
is
null
or an empty string.static java.lang.String[] sortedAcceptLang(java.lang.String acceptLang)
acceptLang
- The accept language header, cannot be null or "".
java.lang.IllegalArgumentException
- If acceptLang
is null or an empty string.static java.util.TreeMap parseConfig(java.util.Properties config, java.lang.String element, java.lang.String language)
element + "_" + language
.
config
- The web module configuration.element
- The sub-element of the web module configuration to process.language
- The language used when generating institution names.
TreeMap
of institution names with full name as
key and ID as value.
java.lang.IllegalArgumentException
- If config
is null
, or if
element
or language
is
null
or an empty string.
java.lang.IllegalStateException
- If no elements of type element
are found in
the configuration config
. Also thrown if the
values found in config
contains less than or
more than one occurrence of the ':' separator character.public static java.lang.String insertLink(java.lang.String token, java.lang.String data, java.lang.String name, java.lang.String url)
token
- The token to replace with link.data
- The data containing text and token(s).name
- The link text.url
- The URL to link to.
java.lang.IllegalArgumentException
- If token, data, name or url is null or an empty string.static java.util.Properties getConfig(javax.servlet.ServletContext context)
context
- ServletContext containing the configuration.
java.lang.IllegalStateException
- If config is not properly set in the context.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |