001/* 
002    Licensed to the Apache Software Foundation (ASF) under one
003    or more contributor license agreements.  See the NOTICE file
004    distributed with this work for additional information
005    regarding copyright ownership.  The ASF licenses this file
006    to you under the Apache License, Version 2.0 (the
007    "License"); you may not use this file except in compliance
008    with the License.  You may obtain a copy of the License at
009
010       http://www.apache.org/licenses/LICENSE-2.0
011
012    Unless required by applicable law or agreed to in writing,
013    software distributed under the License is distributed on an
014    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015    KIND, either express or implied.  See the License for the
016    specific language governing permissions and limitations
017    under the License.  
018 */
019package org.apache.wiki.auth.acl;
020
021import java.util.Properties;
022
023import org.apache.wiki.WikiEngine;
024import org.apache.wiki.WikiPage;
025import org.apache.wiki.auth.WikiSecurityException;
026
027/**
028 *  Specifies how to parse and return ACLs from wiki pages.
029 *  @since 2.3
030 */
031public interface AclManager
032{
033
034    /**
035     * Initializes the AclManager with a supplied wiki engine and properties.
036     * @param engine the wiki engine
037     * @param props the initialization properties
038     */
039    void initialize( WikiEngine engine, Properties props );
040
041    /**
042     * A helper method for parsing textual AccessControlLists. The line is in
043     * form "(ALLOW) <permission><principal>, <principal>, <principal>". This
044     * method was moved from Authorizer.
045     * @param page The current wiki page. If the page already has an ACL, it
046     *            will be used as a basis for this ACL in order to avoid the
047     *            creation of a new one.
048     * @param ruleLine The rule line, as described above.
049     * @return A valid Access Control List. May be empty.
050     * @throws WikiSecurityException if the ruleLine was faulty somehow.
051     * @since 2.1.121
052     */
053    Acl parseAcl( WikiPage page, String ruleLine ) throws WikiSecurityException;
054
055    /**
056     * Returns the access control list for the page.
057     * If the ACL has not been parsed yet, it is done
058     * on-the-fly. If the page has a parent page, then that is tried also.
059     * This method was moved from Authorizer;
060     * it was consolidated with some code from AuthorizationManager.
061     * @param page the wiki page
062     * @since 2.2.121
063     * @return the Acl representing permissions for the page
064     */
065    Acl getPermissions( WikiPage page );
066
067    /**
068     * Sets the access control list for the page and persists it.
069     * @param page the wiki page
070     * @param acl the access control list
071     * @since 2.5
072     * @throws WikiSecurityException if the ACL cannot be set or persisted
073     */
074    void setPermissions( WikiPage page, Acl acl ) throws WikiSecurityException;
075}