當前位置: 首頁>>代碼示例>>Java>>正文


Java ExternalGroupsProvider類代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:SonarQubeCommunity,項目名稱:sonar-activedirectory,代碼行數:37,代碼來源:WindowsGroupsProviderTest.java

示例2: getGroupsProvider

import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
@Override
public ExternalGroupsProvider getGroupsProvider() {
  return windowsGroupsProvider;
}
 
開發者ID:SonarQubeCommunity,項目名稱:sonar-activedirectory,代碼行數:5,代碼來源:WindowsSecurityRealm.java

示例3: getGroupsProvider

import org.sonar.api.security.ExternalGroupsProvider; //導入依賴的package包/類
@Override
public ExternalGroupsProvider getGroupsProvider() {		
	return super.getGroupsProvider();
}
 
開發者ID:mnadeem,項目名稱:sonar-keycloak,代碼行數:5,代碼來源:KeycloakSecurityRealm.java

示例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);
}
 
開發者ID:programmingforliving,項目名稱:sonar-ad-plugin,代碼行數:11,代碼來源:ADSecurityRealm.java


注:本文中的org.sonar.api.security.ExternalGroupsProvider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。