@Test void hasAccessREADWhenLastAuthorHasViewPermissionOnUserDoc() { when(this.authorizationManager.hasAccess(Right.VIEW, this.lastAuthorDocumentReference, this.userDocumentReference)).thenReturn(true); assertTrue(this.authorization.hasAccess("key", this.userReference, ConfigurationRight.READ)); InOrder inOrder = inOrder(this.xcontext); inOrder.verify(this.xcontext).setUserReference(this.userDocumentReference); inOrder.verify(this.xcontext).setUserReference(this.previousCurrentUserDocumentReference); }
@Override public boolean hasAccess(String key, UserReference userReference, ConfigurationRight right) { boolean hasAccess; XWikiContext xcontext = this.contextProvider.get(); XWikiDocument currentDocument = xcontext.getDoc(); if (currentDocument != null) { DocumentReference lastAuthorDocumentReference = xcontext.getAuthorReference(); DocumentReference originalUserReference = this.documentAccessBridge.getCurrentUserReference(); try { xcontext.setUserReference(((DocumentUserReference) userReference).getReference()); hasAccess = super.hasAccess(key, this.documentResolver.resolve(lastAuthorDocumentReference), right); } finally { xcontext.setUserReference(originalUserReference); } } else { hasAccess = super.hasAccess(key, this.currentResolver.resolve(null), right); } return hasAccess; }
NormalUserConfigurationSourceAuthorization extends AbstractDocumentConfigurationSourceAuthorization { @Override public boolean hasAccess(String key, UserReference userReference, ConfigurationRight right) { boolean hasAccess; XWikiContext xcontext = this.contextProvider.get(); XWikiDocument currentDocument = xcontext.getDoc(); if (currentDocument != null) { DocumentReference lastAuthorDocumentReference = xcontext.getAuthorReference(); DocumentReference originalUserReference = this.documentAccessBridge.getCurrentUserReference(); try { xcontext.setUserReference(((DocumentUserReference) userReference).getReference()); hasAccess = super.hasAccess(key, this.documentResolver.resolve(lastAuthorDocumentReference), right); } finally { xcontext.setUserReference(originalUserReference); } } else { hasAccess = super.hasAccess(key, this.currentResolver.resolve(null), right); } return hasAccess; } }
NormalUserConfigurationSourceAuthorization extends AbstractDocumentConfigurationSourceAuthorization { @Override public boolean hasAccess(String key, UserReference userReference, ConfigurationRight right) { boolean hasAccess; XWikiContext xcontext = this.contextProvider.get(); XWikiDocument currentDocument = xcontext.getDoc(); if (currentDocument != null) { DocumentReference lastAuthorDocumentReference = xcontext.getAuthorReference(); DocumentReference originalUserReference = this.documentAccessBridge.getCurrentUserReference(); try { xcontext.setUserReference(((DocumentUserReference) userReference).getReference()); hasAccess = super.hasAccess(key, this.documentResolver.resolve(lastAuthorDocumentReference), right); } finally { xcontext.setUserReference(originalUserReference); } } else { hasAccess = super.hasAccess(key, this.currentResolver.resolve(null), right); } return hasAccess; }  }
NormalUserConfigurationSourceAuthorization extends AbstractDocumentConfigurationSourceAuthorization { @Override public boolean hasAccess(String key, UserReference userReference, ConfigurationRight right) { boolean hasAccess; XWikiContext xcontext = this.contextProvider.get(); XWikiDocument currentDocument = xcontext.getDoc(); if (currentDocument != null) { DocumentReference lastAuthorDocumentReference = xcontext.getAuthorReference(); DocumentReference originalUserReference = this.documentAccessBridge.getCurrentUserReference(); try { xcontext.setUserReference(((DocumentUserReference) userReference).getReference()); hasAccess = super.hasAccess(key, this.documentResolver.resolve(lastAuthorDocumentReference), right); } finally { xcontext.setUserReference(originalUserReference); } } else { hasAccess = super.hasAccess(key, this.currentResolver.resolve(null), right); } return hasAccess; }  @Override boolean hasAccess(String key, UserReference userReference, ConfigurationRight right); }
NormalUserConfigurationSourceAuthorization extends AbstractDocumentConfigurationSourceAuthorization { @Override public boolean hasAccess(String key, UserReference userReference, ConfigurationRight right) { boolean hasAccess; XWikiContext xcontext = this.contextProvider.get(); XWikiDocument currentDocument = xcontext.getDoc(); if (currentDocument != null) { DocumentReference lastAuthorDocumentReference = xcontext.getAuthorReference(); DocumentReference originalUserReference = this.documentAccessBridge.getCurrentUserReference(); try { xcontext.setUserReference(((DocumentUserReference) userReference).getReference()); hasAccess = super.hasAccess(key, this.documentResolver.resolve(lastAuthorDocumentReference), right); } finally { xcontext.setUserReference(originalUserReference); } } else { hasAccess = super.hasAccess(key, this.currentResolver.resolve(null), right); } return hasAccess; }  @Override boolean hasAccess(String key, UserReference userReference, ConfigurationRight right);  }