KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > core > Access


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2005 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.core;
14
15 import java.text.MessageFormat JavaDoc;
16
17 import info.magnolia.cms.security.AccessDeniedException;
18 import info.magnolia.cms.security.AccessManager;
19 import info.magnolia.cms.security.PermissionImpl;
20
21
22 /**
23  * @author Sameer Charles
24  * @version $Revision $ ($Author $)
25  */

26 public final class Access {
27
28     /**
29      * Utility class, don't instantiate.
30      */

31     private Access() {
32         // unused
33
}
34
35     /**
36      * Checks if the accessmanager allows specified permission on the given path
37      * @param manager accessmanager
38      * @param path which needs to be tested using given accessmanager
39      * @param permissions
40      */

41     public static void isGranted(AccessManager manager, String JavaDoc path, long permissions) throws AccessDeniedException {
42         if (manager != null && !manager.isGranted(path, permissions)) {
43             throw new AccessDeniedException(MessageFormat.format("User not allowed to {0} path [{1}]", //$NON-NLS-1$
44
new Object JavaDoc[]{PermissionImpl.getPermissionAsName(permissions), path}));
45         }
46     }
47 }
48
Popular Tags