Package org.sonar.api.security

Examples of org.sonar.api.security.SecurityRealm


  public SecurityRealmFactory(Settings settings, SecurityRealm[] realms, LoginPasswordAuthenticator[] authenticators) {
    ignoreStartupFailure = settings.getBoolean(CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE);
    String realmName = settings.getString(CoreProperties.CORE_AUTHENTICATOR_REALM);
    String className = settings.getString(CoreProperties.CORE_AUTHENTICATOR_CLASS);
    SecurityRealm selectedRealm = null;
    if (!StringUtils.isEmpty(realmName)) {
      selectedRealm = selectRealm(realms, realmName);
      if (selectedRealm == null) {
        throw new SonarException(String.format(
          "Realm '%s' not found. Please check the property '%s' in conf/sonar.properties", realmName, CoreProperties.CORE_AUTHENTICATOR_REALM));
View Full Code Here


  /**
   * Typical usage.
   */
  @Test
  public void should_select_realm_and_start() {
    SecurityRealm realm = spy(new FakeRealm());
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, realm.getName());

    SecurityRealmFactory factory = new SecurityRealmFactory(settings, new SecurityRealm[]{realm});
    factory.start();
    assertThat(factory.getRealm()).isSameAs(realm);
    verify(realm).init();
View Full Code Here

  public void should_provide_compatibility_for_authenticator() {
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, FakeAuthenticator.class.getName());
    LoginPasswordAuthenticator authenticator = new FakeAuthenticator();

    SecurityRealmFactory factory = new SecurityRealmFactory(settings, new LoginPasswordAuthenticator[]{authenticator});
    SecurityRealm realm = factory.getRealm();
    assertThat(realm).isInstanceOf(CompatibilityRealm.class);
  }
View Full Code Here

    assertThat(realm).isInstanceOf(CompatibilityRealm.class);
  }

  @Test
  public void should_take_precedence_over_authenticator() {
    SecurityRealm realm = new FakeRealm();
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, realm.getName());
    LoginPasswordAuthenticator authenticator = new FakeAuthenticator();
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_CLASS, FakeAuthenticator.class.getName());

    SecurityRealmFactory factory = new SecurityRealmFactory(settings, new SecurityRealm[]{realm},
      new LoginPasswordAuthenticator[]{authenticator});
View Full Code Here

    }
  }

  @Test
  public void ignore_startup_failure() {
    SecurityRealm realm = spy(new AlwaysFailsRealm());
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, realm.getName());
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE, true);

    new SecurityRealmFactory(settings, new SecurityRealm[]{realm}).start();
    verify(realm).init();
  }
View Full Code Here

    verify(realm).init();
  }

  @Test
  public void should_fail() {
    SecurityRealm realm = spy(new AlwaysFailsRealm());
    settings.setProperty(CoreProperties.CORE_AUTHENTICATOR_REALM, realm.getName());

    try {
      new SecurityRealmFactory(settings, new SecurityRealm[]{realm}).start();
      fail();
    } catch (SonarException e) {
View Full Code Here

TOP

Related Classes of org.sonar.api.security.SecurityRealm

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.