org.apache.wiki.auth.acl
Class DefaultAclManager

java.lang.Object
  extended by org.apache.wiki.auth.acl.DefaultAclManager
All Implemented Interfaces:
AclManager

public class DefaultAclManager
extends Object
implements AclManager

Default implementation that parses Acls from wiki page markup.

Since:
2.3

Field Summary
static Pattern ACL_PATTERN
          Identifies ACL strings in wiki text; the first group is the action (view, edit) and the second is the list of Principals separated by commas.
 
Constructor Summary
DefaultAclManager()
           
 
Method Summary
 Acl getPermissions(WikiPage page)
          Returns the access control list for the page.
 void initialize(WikiEngine engine, Properties props)
          Initializes the AclManager with a supplied wiki engine and properties.
 Acl parseAcl(WikiPage page, String ruleLine)
          A helper method for parsing textual AccessControlLists.
protected static String printAcl(Acl acl)
          Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object.
 void setPermissions(WikiPage page, Acl acl)
          Sets the access control list for the page and persists it by prepending it to the wiki page markup and saving the page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACL_PATTERN

public static final Pattern ACL_PATTERN
Identifies ACL strings in wiki text; the first group is the action (view, edit) and the second is the list of Principals separated by commas. The overall match is the ACL string from [{ to }].

Constructor Detail

DefaultAclManager

public DefaultAclManager()
Method Detail

initialize

public void initialize(WikiEngine engine,
                       Properties props)
Initializes the AclManager with a supplied wiki engine and properties.

Specified by:
initialize in interface AclManager
Parameters:
engine - the wiki engine
props - the initialization properties
See Also:
AclManager.initialize(org.apache.wiki.WikiEngine, java.util.Properties)

parseAcl

public Acl parseAcl(WikiPage page,
                    String ruleLine)
             throws WikiSecurityException
A helper method for parsing textual AccessControlLists. The line is in form "ALLOW , , ". This method was moved from Authorizer.

Specified by:
parseAcl in interface AclManager
Parameters:
page - The current wiki page. If the page already has an ACL, it will be used as a basis for this ACL in order to avoid the creation of a new one.
ruleLine - The rule line, as described above.
Returns:
A valid Access Control List. May be empty.
Throws:
WikiSecurityException - if the ruleLine was faulty somehow.
Since:
2.1.121

getPermissions

public Acl getPermissions(WikiPage page)
Returns the access control list for the page. If the ACL has not been parsed yet, it is done on-the-fly. If the page has a parent page, then that is tried also. This method was moved from Authorizer; it was consolidated with some code from AuthorizationManager. This method is guaranteed to return a non-null Acl.

Specified by:
getPermissions in interface AclManager
Parameters:
page - the page
Returns:
the Acl representing permissions for the page
Since:
2.2.121

setPermissions

public void setPermissions(WikiPage page,
                           Acl acl)
                    throws WikiSecurityException
Sets the access control list for the page and persists it by prepending it to the wiki page markup and saving the page. When this method is called, all other ACL markup in the page is removed. This method will forcibly expire locks on the wiki page if they exist. Any ProviderExceptions will be re-thrown as WikiSecurityExceptions.

Specified by:
setPermissions in interface AclManager
Parameters:
page - the wiki page
acl - the access control list
Throws:
WikiSecurityException - of the Acl cannot be set
Since:
2.5

printAcl

protected static String printAcl(Acl acl)
Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object. All of the permissions in this Acl are assumed to apply to the same page scope. The names of the pages are ignored; only the actions and principals matter.

Parameters:
acl - the ACL
Returns:
the ACL string


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.