|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wiki.auth.authorize.WebContainerAuthorizer
public class WebContainerAuthorizer

Authorizes users by delegating role membership checks to the servlet
container. In addition to implementing methods for the
Authorizer interface, this class also provides a convenience
method isContainerAuthorized() that queries the web application
descriptor to determine if the container manages authorization.
| Nested Class Summary | |
|---|---|
class |
WebContainerAuthorizer.LocalEntityResolver
XML entity resolver that redirects resolution requests by JDOM, JAXP and other XML parsers to locally-cached copies of the resources. |
| Field Summary | |
|---|---|
protected static org.apache.log4j.Logger |
log
|
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 Summary | |
|---|---|
WebContainerAuthorizer()
Constructs a new instance of the WebContainerAuthorizer class. |
|
| Method Summary | |
|---|---|
Principal |
findRole(String role)
Looks up and returns a Role Principal matching a given String. |
Principal[] |
getRoles()
Returns an array of role Principals this Authorizer knows about. |
protected Role[] |
getRoles(org.jdom2.Document webxml)
Protected method that extracts the roles from JSPWiki's web application deployment descriptor. |
protected org.jdom2.Document |
getWebXml()
Returns an Document representing JSPWiki's web
application deployment descriptor. |
void |
initialize(WikiEngine engine,
Properties props)
Initializes the authorizer for. |
boolean |
isConstrained(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(javax.servlet.http.HttpServletRequest request,
Principal role)
Determines whether a user associated with an HTTP request possesses a particular role. |
boolean |
isUserInRole(WikiSession session,
Principal role)
Determines whether the Subject associated with a WikiSession is in a particular role. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.log4j.Logger log
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
| Constructor Detail |
|---|
public WebContainerAuthorizer()
| Method Detail |
|---|
public void initialize(WikiEngine engine,
Properties props)
initialize in interface Authorizerengine - the current wiki engineprops - the wiki engine initialization properties
public boolean isUserInRole(javax.servlet.http.HttpServletRequest request,
Principal role)
HttpServletRequest.isUserInRole(String)
by converting the Principal's name to a String.
isUserInRole in interface WebAuthorizerrequest - the HTTP requestrole - the role to check
true if the user is considered to be in the role,
false otherwise
public boolean isUserInRole(WikiSession session,
Principal role)
null, this method must
return false.
This method simply examines the WikiSession subject to see if it
possesses the desired Principal. We assume that the method
WikiServletFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
previously executed, and that it has set the WikiSession
subject correctly by logging in the user with the various login modules,
in particular WebContainerLoginModule}.
This is definitely a hack,
but it eliminates the need for WikiSession to keep dangling
references to the last WikiContext hanging around, just
so we can look up the HttpServletRequest.
isUserInRole in interface Authorizersession - the current WikiSessionrole - the role to check
true if the user is considered to be in the role,
false otherwiseAuthorizer.isUserInRole(org.apache.wiki.WikiSession, java.security.Principal)public Principal findRole(String role)
null.
findRole in interface Authorizerrole - the name of the Role to retrieve
nullAuthorizer.initialize(WikiEngine, Properties)
public boolean isConstrained(String url,
Role role)
throws org.jdom2.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 roles
url - the web resourcerole - the role
true if the resource is constrained to the role,
false otherwise
org.jdom2.JDOMException - 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 Principal[] getRoles()
web.xml.
This method actually returns a defensive copy of an internally stored
array.
getRoles in interface Authorizer
protected Role[] getRoles(org.jdom2.Document webxml)
throws org.jdom2.JDOMException
new Role("Administrator").
webxml - the web application deployment descriptor
org.jdom2.JDOMException - if elements cannot be parsed correctly
protected org.jdom2.Document getWebXml()
throws org.jdom2.JDOMException,
IOException
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.
IOException - if the deployment descriptor cannot be found or opened
org.jdom2.JDOMException - if the deployment descriptor cannot be parsed correctly
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||