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 org.apache.wiki.api.core.Acl;
022import org.apache.wiki.api.core.Page;
023import org.apache.wiki.api.engine.Initializable;
024import org.apache.wiki.auth.WikiSecurityException;
025
026/**
027 *  Specifies how to parse and return ACLs from wiki pages.
028 *
029 *  @since 2.3
030 */
031public interface AclManager extends Initializable {
032
033    /**
034     * A helper method for parsing textual AccessControlLists. The line is in form
035     * "(ALLOW) <permission><principal>, <principal>, <principal>". This method was moved from Authorizer.
036     *
037     * @param 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
038     *             creation of a new one.
039     * @param ruleLine The rule line, as described above.
040     * @return A valid Access Control List. May be empty.
041     * @throws WikiSecurityException if the ruleLine was faulty somehow.
042     * @since 2.1.121
043     */
044    Acl parseAcl( Page page, String ruleLine ) throws WikiSecurityException;
045
046    /**
047     * 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
048     * parent page, then that is tried also. This method was moved from Authorizer; it was consolidated with some code from
049     * AuthorizationManager.
050     *
051     * @param page the wiki page
052     * @since 2.2.121
053     * @return the Acl representing permissions for the page
054     */
055    Acl getPermissions( Page page );
056
057    /**
058     * Sets the access control list for the page and persists it.
059     *
060     * @param page the wiki page
061     * @param acl the access control list
062     * @since 2.5
063     * @throws WikiSecurityException if the ACL cannot be set or persisted
064     */
065    void setPermissions( Page page, Acl acl ) throws WikiSecurityException;
066
067}