@Test public void checkAccessWithNullUserAndFailedAuthentication() throws XWikiException { when(this.context.getUserReference()).thenReturn(null); when(this.xwiki.checkAuth(this.context)).thenThrow(new XWikiException()); Assert.assertFalse(this.service.checkAccess("view", this.document, this.context)); }
@Override public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException { DocumentReference userReference = getCurrentUser(context); User user = this.userManager.getUser(userReference != null ? userReference.toString() : null, true); boolean result = this.service.hasAccess(user, actionToRight(action), doc.getDocumentReference()); if (!result && context.getUserReference() == null && !"login".equals(context.getAction())) { this.logger.debug("Redirecting unauthenticated user to login, since it have been denied [{}] on [{}].", actionToRight(action), doc.getDocumentReference()); context.getWiki().getAuthService().showLogin(context); } return result; }
ModularRightServiceImpl extends XWikiCachingRightService implements XWikiRightService { @Override public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException { DocumentReference userReference = getCurrentUser(context); User user = this.userManager.getUser(userReference != null ? userReference.toString() : null, true); boolean result = this.service.hasAccess(user, actionToRight(action), doc.getDocumentReference()); if (!result && context.getUserReference() == null && !"login".equals(context.getAction())) { this.logger.debug("Redirecting unauthenticated user to login, since it have been denied [{}] on [{}].", actionToRight(action), doc.getDocumentReference()); context.getWiki().getAuthService().showLogin(context); } return result; } }
ModularRightServiceImpl extends XWikiCachingRightService implements XWikiRightService { @Override public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException { DocumentReference userReference = getCurrentUser(context); User user = this.userManager.getUser(userReference != null ? userReference.toString() : null, true); boolean result = this.service.hasAccess(user, actionToRight(action), doc.getDocumentReference()); if (!result && context.getUserReference() == null && !"login".equals(context.getAction())) { this.logger.debug("Redirecting unauthenticated user to login, since it have been denied [{}] on [{}].", actionToRight(action), doc.getDocumentReference()); context.getWiki().getAuthService().showLogin(context); } return result; }  }
ModularRightServiceImpl extends XWikiCachingRightService implements XWikiRightService { @Override public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException { DocumentReference userReference = getCurrentUser(context); User user = this.userManager.getUser(userReference != null ? userReference.toString() : null, true); boolean result = this.service.hasAccess(user, actionToRight(action), doc.getDocumentReference()); if (!result && context.getUserReference() == null && !"login".equals(context.getAction())) { this.logger.debug("Redirecting unauthenticated user to login, since it have been denied [{}] on [{}].", actionToRight(action), doc.getDocumentReference()); context.getWiki().getAuthService().showLogin(context); } return result; }  @Override boolean checkAccess(String action, XWikiDocument doc, XWikiContext context); @Override boolean hasAccessLevel(String right, String username, String docname, XWikiContext context); }
ModularRightServiceImpl extends XWikiCachingRightService implements XWikiRightService { @Override public boolean checkAccess(String action, XWikiDocument doc, XWikiContext context) throws XWikiException { DocumentReference userReference = getCurrentUser(context); User user = this.userManager.getUser(userReference != null ? userReference.toString() : null, true); boolean result = this.service.hasAccess(user, actionToRight(action), doc.getDocumentReference()); if (!result && context.getUserReference() == null && !"login".equals(context.getAction())) { this.logger.debug("Redirecting unauthenticated user to login, since it have been denied [{}] on [{}].", actionToRight(action), doc.getDocumentReference()); context.getWiki().getAuthService().showLogin(context); } return result; }  @Override boolean checkAccess(String action, XWikiDocument doc, XWikiContext context); @Override boolean hasAccessLevel(String right, String username, String docname, XWikiContext context);  }