Search in sources :

Example 6 with AllPermission

use of org.apache.wiki.auth.permissions.AllPermission in project jspwiki by apache.

the class AuthorizationManagerTest method testAdminView.

@Test
public void testAdminView() throws Exception {
    m_engine.saveText("TestDefaultPage", "Foo [{ALLOW view FooBar}]");
    Principal admin = new GroupPrincipal("Admin");
    WikiSession session = WikiSessionTest.containerAuthenticatedSession(m_engine, Users.ALICE, new Principal[] { admin });
    Assert.assertTrue("Alice has AllPermission", m_auth.checkPermission(session, new AllPermission(m_engine.getApplicationName())));
    Assert.assertTrue("Alice cannot read", m_auth.checkPermission(session, new PagePermission("TestDefaultPage", "view")));
}
Also used : WikiSession(org.apache.wiki.WikiSession) AllPermission(org.apache.wiki.auth.permissions.AllPermission) Principal(java.security.Principal) UnresolvedPrincipal(org.apache.wiki.auth.acl.UnresolvedPrincipal) PagePermission(org.apache.wiki.auth.permissions.PagePermission) WikiSessionTest(org.apache.wiki.WikiSessionTest) Test(org.junit.Test)

Example 7 with AllPermission

use of org.apache.wiki.auth.permissions.AllPermission in project jspwiki by apache.

the class UserManager method initialize.

/**
 * Initializes the engine for its nefarious purposes.
 * @param engine the current wiki engine
 * @param props the wiki engine initialization properties
 */
public void initialize(WikiEngine engine, Properties props) {
    m_engine = engine;
    // Attach the PageManager as a listener
    // TODO: it would be better if we did this in PageManager directly
    addWikiEventListener(engine.getPageManager());
    // TODO: Replace with custom annotations. See JSPWIKI-566
    WikiAjaxDispatcherServlet.registerServlet(JSON_USERS, new JSONUserModule(this), new AllPermission(null));
}
Also used : AllPermission(org.apache.wiki.auth.permissions.AllPermission)

Aggregations

AllPermission (org.apache.wiki.auth.permissions.AllPermission)7 Permission (java.security.Permission)3 Principal (java.security.Principal)3 WikiSession (org.apache.wiki.WikiSession)3 PagePermission (org.apache.wiki.auth.permissions.PagePermission)3 WikiPage (org.apache.wiki.WikiPage)2 WikiSessionTest (org.apache.wiki.WikiSessionTest)2 UnresolvedPrincipal (org.apache.wiki.auth.acl.UnresolvedPrincipal)2 GroupPermission (org.apache.wiki.auth.permissions.GroupPermission)2 WikiPermission (org.apache.wiki.auth.permissions.WikiPermission)2 Test (org.junit.Test)2 AuthorizationManager (org.apache.wiki.auth.AuthorizationManager)1 GroupPrincipal (org.apache.wiki.auth.GroupPrincipal)1 NoSuchPrincipalException (org.apache.wiki.auth.NoSuchPrincipalException)1 UserManager (org.apache.wiki.auth.UserManager)1 Acl (org.apache.wiki.auth.acl.Acl)1 AclEntry (org.apache.wiki.auth.acl.AclEntry)1 UserDatabase (org.apache.wiki.auth.user.UserDatabase)1 Command (org.apache.wiki.ui.Command)1 GroupCommand (org.apache.wiki.ui.GroupCommand)1