本文整理匯總了Java中org.sonar.api.security.ExternalGroupsProvider類的典型用法代碼示例。如果您正苦於以下問題:Java ExternalGroupsProvider類的具體用法?Java ExternalGroupsProvider怎麽用?Java ExternalGroupsProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ExternalGroupsProvider類屬於org.sonar.api.security包,在下文中一共展示了ExternalGroupsProvider類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: runDoGetGroupsTest
import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
private void runDoGetGroupsTest(boolean isUserAuthenticatedByBasicAuth, boolean doesUserExist,
Collection<WindowsAccount> windowsAccounts, Collection<String> expectedGroups) {
WindowsPrincipal windowsPrincipal = null;
int getUserGroupsInvCount = 0;
if (doesUserExist) {
windowsPrincipal = Mockito.mock(WindowsPrincipal.class);
getUserGroupsInvCount = 1;
}
HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
ExternalGroupsProvider.Context context = new ExternalGroupsProvider.Context(null, httpServletRequest);
String windowsPrincipalKey = WindowsAuthenticationHelper.SSO_PRINCIPAL_KEY;
if (isUserAuthenticatedByBasicAuth) {
windowsPrincipalKey = WindowsAuthenticationHelper.BASIC_AUTH_PRINCIPAL_KEY;
}
WindowsAuthenticationHelper windowsAuthenticationHelper = Mockito.mock(WindowsAuthenticationHelper.class);
when(windowsAuthenticationHelper.getWindowsPrincipal(httpServletRequest, windowsPrincipalKey)).thenReturn(windowsPrincipal);
if (doesUserExist) {
when(windowsAuthenticationHelper.getUserGroups(windowsPrincipal)).thenReturn(expectedGroups);
}
WindowsGroupsProvider groupsProvider = new WindowsGroupsProvider(windowsAuthenticationHelper);
Collection<String> groups = groupsProvider.doGetGroups(context);
if (expectedGroups == null) {
assertThat(groups).isNull();
verify(windowsAuthenticationHelper, Mockito.times(getUserGroupsInvCount)).getUserGroups(windowsPrincipal);
} else {
assertThat(groups).isNotNull().hasSameElementsAs(expectedGroups);
verify(windowsAuthenticationHelper, Mockito.times(getUserGroupsInvCount)).getUserGroups(windowsPrincipal);
}
}
示例2: getGroupsProvider
import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
@Override
public ExternalGroupsProvider getGroupsProvider() {
return windowsGroupsProvider;
}
示例3: getGroupsProvider
import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
@Override
public ExternalGroupsProvider getGroupsProvider() {
return super.getGroupsProvider();
}
示例4: getGroupsProvider
import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
/**
* Return ExternalGroupsProvider.
*
* @return {@link ExternalGroupsProvider} associated with this realm, null
* if not supported
*/
@Override
public ExternalGroupsProvider getGroupsProvider() {
return new ADGroupsProvider(adSettings);
}