KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > riotfamily > riot > security > policy > LoggingPolicy


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1
3  * The contents of this file are subject to the Mozilla Public License Version
4  * 1.1 (the "License"); you may not use this file except in compliance with
5  * the License. You may obtain a copy of the License at
6  * http://www.mozilla.org/MPL/
7  *
8  * Software distributed under the License is distributed on an "AS IS" basis,
9  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10  * for the specific language governing rights and limitations under the
11  * License.
12  *
13  * The Original Code is Riot.
14  *
15  * The Initial Developer of the Original Code is
16  * Neteye GmbH
17  * artundweise GmbH
18  * Portions created by the Initial Developer are Copyright (C) 2006
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Felix Gnass [fgnass at neteye dot de]
23  * Alf Werder [alf dot werder at artundweise dot de]
24  *
25  * ***** END LICENSE BLOCK ***** */

26 package org.riotfamily.riot.security.policy;
27
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30 import org.riotfamily.riot.security.auth.RiotUser;
31
32 /**
33  * A logging policy for debugging purposes.
34  *
35  * @since 6.5
36  * @author Alf Werder [alf dot werder at artundweise dot de]
37  */

38 public class LoggingPolicy implements AuthorizationPolicy {
39     
40     private static final Log log = LogFactory.getLog(LoggingPolicy.class);
41     
42     private int order = Integer.MIN_VALUE;
43     
44     public int getOrder() {
45         return this.order;
46     }
47     
48     public void setOrder(int order) {
49         this.order = order;
50     }
51
52     public int checkPermission(RiotUser user, String JavaDoc action, Object JavaDoc object) {
53         if (log.isDebugEnabled()) {
54             StringBuffer JavaDoc message = new StringBuffer JavaDoc();
55             message.append("user: [").append(user.getUserId()).append("], ");
56             message.append("action: [").append(action).append("], ");
57             message.append("object: ");
58             if (object != null) {
59                 message.append(object.getClass().getName());
60             }
61             message.append("[").append(object).append("]");
62             
63             log.debug(message.toString());
64         }
65         return ACCESS_ABSTAIN;
66     }
67
68 }
69
Popular Tags