Search in sources :

Example 16 with AccessDeniedException

use of org.xwiki.security.authorization.AccessDeniedException in project xwiki-platform by xwiki.

the class WikiTemplateManagerScriptTest method currentUserHasNotAdminRight.

/**
 * @return the exception expected when the current user has the not the admin right
 */
private Exception currentUserHasNotAdminRight() throws AccessDeniedException {
    WikiReference wiki = new WikiReference("wikiId");
    Exception exception = new AccessDeniedException(Right.ADMIN, currentUserRef, wiki);
    doThrow(exception).when(authorizationManager).checkAccess(eq(Right.ADMIN), eq(currentUserRef), eq(wiki));
    return exception;
}
Also used : AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiReference(org.xwiki.model.reference.WikiReference) WikiTemplateManagerException(org.xwiki.wiki.template.WikiTemplateManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException)

Example 17 with AccessDeniedException

use of org.xwiki.security.authorization.AccessDeniedException in project xwiki-platform by xwiki.

the class WikiTemplateManagerScriptTest method currentScriptHasNotProgrammingRight.

/**
 * @return the exception expected when the current script has the not the programing right
 */
private Exception currentScriptHasNotProgrammingRight() throws AccessDeniedException {
    DocumentReference authorDocRef = new DocumentReference("mainWiki", "XWiki", "Admin");
    when(currentDoc.getAuthorReference()).thenReturn(authorDocRef);
    DocumentReference currentDocRef = new DocumentReference("subwiki", "Test", "test");
    when(currentDoc.getDocumentReference()).thenReturn(currentDocRef);
    Exception exception = new AccessDeniedException(Right.PROGRAM, authorDocRef, currentDocRef);
    doThrow(exception).when(authorizationManager).checkAccess(Right.PROGRAM, authorDocRef, currentDocRef);
    return exception;
}
Also used : AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) DocumentReference(org.xwiki.model.reference.DocumentReference) WikiTemplateManagerException(org.xwiki.wiki.template.WikiTemplateManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException)

Example 18 with AccessDeniedException

use of org.xwiki.security.authorization.AccessDeniedException in project xwiki-platform by xwiki.

the class WikiTemplateManagerScriptTest method currentUserHasNotCreateWikiRight.

/**
 * @return the exception expected when the current user has the not the 'create wiki' right
 */
private Exception currentUserHasNotCreateWikiRight() throws AccessDeniedException {
    WikiReference wiki = new WikiReference("mainWiki");
    Exception exception = new AccessDeniedException(Right.CREATE_WIKI, currentUserRef, wiki);
    doThrow(exception).when(authorizationManager).checkAccess(eq(Right.CREATE_WIKI), eq(currentUserRef), eq(wiki));
    return exception;
}
Also used : AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiReference(org.xwiki.model.reference.WikiReference) WikiTemplateManagerException(org.xwiki.wiki.template.WikiTemplateManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException)

Aggregations

AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)18 WikiReference (org.xwiki.model.reference.WikiReference)13 WikiManagerException (org.xwiki.wiki.manager.WikiManagerException)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 Test (org.junit.Test)5 WikiTemplateManagerException (org.xwiki.wiki.template.WikiTemplateManagerException)5 XWikiContext (com.xpn.xwiki.XWikiContext)4 WikiDescriptor (org.xwiki.wiki.descriptor.WikiDescriptor)4 WikiUserManagerException (org.xwiki.wiki.user.WikiUserManagerException)2 NotificationException (org.xwiki.notifications.NotificationException)1 WikiCreationException (org.xwiki.platform.wiki.creationjob.WikiCreationException)1 WikiCreationRequest (org.xwiki.platform.wiki.creationjob.WikiCreationRequest)1 AuthorizationException (org.xwiki.security.authorization.AuthorizationException)1