@Test public void getUserGlobalFound() throws XWikiException { when(context.getMainXWiki()).thenReturn("mainwiki"); DocumentReference globalReference = new DocumentReference("mainwiki", "XWiki", "foo"); DocumentReference localReference = new DocumentReference("currentwiki", "XWiki", "foo"); XWiki xwiki = mock(XWiki.class); XWikiDocument xWikiDocument = mock(XWikiDocument.class); when(context.getWiki()).thenReturn(xwiki); when(xwiki.getDocument(eq(globalReference), eq(context))).thenReturn(xWikiDocument); when(xWikiDocument.isNew()).thenReturn(false); DocumentReference userReference = this.defaultAuthenticationFailureManager.findUser("foo"); assertEquals(globalReference, userReference); verify(xwiki, times(1)).getDocument(eq(globalReference), eq(context)); verify(xwiki, never()).getDocument(eq(localReference), eq(context)); }
@Override public DocumentReference findUser(String username) { DocumentReference result = null; XWikiContext context = this.contextProvider.get(); String globalWiki = context.getMainXWiki(); XWikiUser globalXWikiUser = new XWikiUser(buildUserDocumentReference(globalWiki, username)); if (globalXWikiUser.exists(context)) { result = globalXWikiUser.getUserReference(); } else { String localWiki = context.getWikiId(); XWikiUser localXWikiUser = new XWikiUser(buildUserDocumentReference(localWiki, username)); if (localXWikiUser.exists(context)) { result = localXWikiUser.getUserReference(); } } return result; }
DefaultAuthenticationFailureManager implements AuthenticationFailureManager { @Override public DocumentReference findUser(String username) { DocumentReference result = null; XWikiContext context = this.contextProvider.get(); String globalWiki = context.getMainXWiki(); XWikiUser globalXWikiUser = new XWikiUser(buildUserDocumentReference(globalWiki, username)); if (globalXWikiUser.exists(context)) { result = globalXWikiUser.getUserReference(); } else { String localWiki = context.getWikiId(); XWikiUser localXWikiUser = new XWikiUser(buildUserDocumentReference(localWiki, username)); if (localXWikiUser.exists(context)) { result = localXWikiUser.getUserReference(); } } return result; } }
DefaultAuthenticationFailureManager implements AuthenticationFailureManager { @Override public DocumentReference findUser(String username) { DocumentReference result = null; XWikiContext context = this.contextProvider.get(); String globalWiki = context.getMainXWiki(); XWikiUser globalXWikiUser = new XWikiUser(buildUserDocumentReference(globalWiki, username)); if (globalXWikiUser.exists(context)) { result = globalXWikiUser.getUserReference(); } else { String localWiki = context.getWikiId(); XWikiUser localXWikiUser = new XWikiUser(buildUserDocumentReference(localWiki, username)); if (localXWikiUser.exists(context)) { result = localXWikiUser.getUserReference(); } } return result; } DefaultAuthenticationFailureManager(); }
DefaultAuthenticationFailureManager implements AuthenticationFailureManager { @Override public DocumentReference findUser(String username) { DocumentReference result = null; XWikiContext context = this.contextProvider.get(); String globalWiki = context.getMainXWiki(); XWikiUser globalXWikiUser = new XWikiUser(buildUserDocumentReference(globalWiki, username)); if (globalXWikiUser.exists(context)) { result = globalXWikiUser.getUserReference(); } else { String localWiki = context.getWikiId(); XWikiUser localXWikiUser = new XWikiUser(buildUserDocumentReference(localWiki, username)); if (localXWikiUser.exists(context)) { result = localXWikiUser.getUserReference(); } } return result; } DefaultAuthenticationFailureManager(); @Override boolean recordAuthenticationFailure(String username); @Override void resetAuthenticationFailureCounter(DocumentReference user); @Override void resetAuthenticationFailureCounter(String username); @Override String getForm(String username); @Override boolean validateForm(String username, SecurityRequestWrapper request); @Override String getErrorMessage(String username); @Override DocumentReference findUser(String username); }
DefaultAuthenticationFailureManager implements AuthenticationFailureManager { @Override public DocumentReference findUser(String username) { DocumentReference result = null; XWikiContext context = this.contextProvider.get(); String globalWiki = context.getMainXWiki(); XWikiUser globalXWikiUser = new XWikiUser(buildUserDocumentReference(globalWiki, username)); if (globalXWikiUser.exists(context)) { result = globalXWikiUser.getUserReference(); } else { String localWiki = context.getWikiId(); XWikiUser localXWikiUser = new XWikiUser(buildUserDocumentReference(localWiki, username)); if (localXWikiUser.exists(context)) { result = localXWikiUser.getUserReference(); } } return result; } DefaultAuthenticationFailureManager(); @Override boolean recordAuthenticationFailure(String username); @Override void resetAuthenticationFailureCounter(DocumentReference user); @Override void resetAuthenticationFailureCounter(String username); @Override String getForm(String username); @Override boolean validateForm(String username, SecurityRequestWrapper request); @Override String getErrorMessage(String username); @Override DocumentReference findUser(String username);  }