public class WebContainerAuthorizer extends java.lang.Object implements WebAuthorizer
Authorizer interface, this class also provides a convenience
method isContainerAuthorized() that queries the web application
descriptor to determine if the container manages authorization.| Modifier and Type | Class and Description |
|---|---|
class |
WebContainerAuthorizer.LocalEntityResolver
XML entity resolver that redirects resolution requests by JDOM, JAXP and
other XML parsers to locally-cached copies of the resources.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
m_containerAuthorized
Lazily-initialized boolean flag indicating whether the web container
protects JSPWiki resources.
|
protected Role[] |
m_containerRoles
A lazily-initialized array of Roles that the container knows about.
|
protected WikiEngine |
m_engine |
| Constructor and Description |
|---|
WebContainerAuthorizer()
Constructs a new instance of the WebContainerAuthorizer class.
|
| Modifier and Type | Method and Description |
|---|---|
java.security.Principal |
findRole(java.lang.String role)
Looks up and returns a Role Principal matching a given String.
|
java.security.Principal[] |
getRoles()
Returns an array of role Principals this Authorizer knows about.
|
protected Role[] |
getRoles(Document webxml)
Protected method that extracts the roles from JSPWiki's web application
deployment descriptor.
|
protected Document |
getWebXml()
Returns an
org.jdom2.Document representing JSPWiki's web
application deployment descriptor. |
void |
initialize(WikiEngine engine,
java.util.Properties props)
Initializes the authorizer for.
|
boolean |
isConstrained(java.lang.String url,
Role role)
Protected method that identifies whether a particular webapp URL is
constrained to a particular Role.
|
boolean |
isContainerAuthorized()
Returns
true if the web container is configured to protect
certain JSPWiki resources by requiring authentication. |
boolean |
isUserInRole(HttpServletRequest request,
java.security.Principal role)
Determines whether a user associated with an HTTP request possesses
a particular role.
|
protected WikiEngine m_engine
protected Role[] m_containerRoles
web.xml web application
deployment descriptor. If this file cannot be read for any reason, the
role list will be empty. This is a hack designed to get around the fact
that we have no direct way of querying the web container about which
roles it manages.protected boolean m_containerAuthorized
public WebContainerAuthorizer()
public void initialize(WikiEngine engine, java.util.Properties props)
initialize in interface Authorizerengine - the current wiki engineprops - the wiki engine initialization propertiespublic boolean isUserInRole(HttpServletRequest request,
java.security.Principal role)
javax.servlet.http.HttpServletRequest#isUserInRole(String)
by converting the Principal's name to a String.isUserInRole in interface WebAuthorizerisUserInRole in interface Authorizerrequest - the HTTP requestrole - the role to checktrue if the user is considered to be in the role,
false otherwisepublic java.security.Principal findRole(java.lang.String role)
null.findRole in interface Authorizerrole - the name of the Role to retrievenullAuthorizer.initialize(WikiEngine, Properties)public boolean isConstrained(java.lang.String url,
Role role)
throws JDOMException
Protected method that identifies whether a particular webapp URL is constrained to a particular Role. The resource is considered constrained if:
security-constraint with a child
web-resource-collection/url-pattern element matching the
URL, and:auth-constraint/role-name element equal to the supplied
Role's getName() method. If the supplied Role is Role.ALL,
it matches all rolesurl - the web resourcerole - the roletrue if the resource is constrained to the role,
false otherwiseJDOMException - if elements cannot be parsed correctlypublic boolean isContainerAuthorized()
true if the web container is configured to protect
certain JSPWiki resources by requiring authentication. Specifically, this
method parses JSPWiki's web application descriptor (web.xml)
and identifies whether the string representation of
Role.AUTHENTICATED is required
to access /Delete.jsp and LoginRedirect.jsp.
If the administrator has uncommented the large
<security-constraint> section of web.xml,
this will be true. This is admittedly an indirect way to go about it, but
it should be an accurate test for default installations, and also in 99%
of customized installs.true if the container protects resources,
false otherwisepublic java.security.Principal[] getRoles()
web.xml.
This method actually returns a defensive copy of an internally stored
array.getRoles in interface Authorizerprotected Role[] getRoles(Document webxml) throws JDOMException
new Role("Administrator").webxml - the web application deployment descriptorJDOMException - if elements cannot be parsed correctlyprotected Document getWebXml()
throws JDOMException,
java.io.IOException
org.jdom2.Document representing JSPWiki's web
application deployment descriptor. The document is obtained by calling
the servlet context's getResource() method and requesting
/WEB-INF/web.xml. For non-servlet applications, this
method calls this class'
ClassLoader.getResource(java.lang.String) and requesting
WEB-INF/web.xml.java.io.IOException - if the deployment descriptor cannot be found or openedJDOMException - if the deployment descriptor cannot be parsed correctlystSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.