本文整理汇总了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);
}