Examples of CConnectionInfo


Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

             InvalidConfigurationException
  {

    LdapAuthenticationTestRequest authRequest = (LdapAuthenticationTestRequest) payload;

    CConnectionInfo connectionInfo = this.toLdapModel(authRequest.getData());
    String ldapServerId = null;
    if (request.getResourceRef() != null) {
      ldapServerId = request.getResourceRef().getQueryAsForm().getFirstValue("ldapServerId");
    }
    replaceFakePassword(connectionInfo, ldapServerId, ldapConfigurationManager);
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    dto.setId(ldapServer.getId());
    dto.setName(ldapServer.getName());

    if (ldapServer.getConnectionInfo() != null) {
      CConnectionInfo connInfo = ldapServer.getConnectionInfo();

      LdapConnectionInfoDTO infoDto = new LdapConnectionInfoDTO();
      infoDto.setAuthScheme(connInfo.getAuthScheme());
      infoDto.setBackupMirrorHost(connInfo.getBackupMirrorHost());
      infoDto.setBackupMirrorPort(connInfo.getBackupMirrorPort());
      infoDto.setBackupMirrorProtocol(connInfo.getBackupMirrorProtocol());
      infoDto.setCacheTimeout(connInfo.getCacheTimeout());
      infoDto.setConnectionRetryDelay(connInfo.getConnectionRetryDelay());
      infoDto.setConnectionTimeout(connInfo.getConnectionTimeout());
      infoDto.setHost(connInfo.getHost());
      infoDto.setPort(connInfo.getPort());
      infoDto.setProtocol(connInfo.getProtocol());
      infoDto.setRealm(connInfo.getRealm());
      infoDto.setSearchBase(connInfo.getSearchBase());
      infoDto.setSystemUsername(connInfo.getSystemUsername());
      if (connInfo.getSystemPassword() != null) {
        infoDto.setSystemPassword(FAKE_PASSWORD);
      }
      dto.setConnectionInfo(encode(infoDto));
    }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

  }

  protected CConnectionInfo toLdapModel(LdapConnectionInfoDTO connectionDto)
      throws ResourceException, InvalidConfigurationException
  {
    return decode(convert(connectionDto, new CConnectionInfo()));
  }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

      newConfiguration.addServer(newServerConfig);
      new LdapConfigurationXpp3Writer().write(writer, newConfiguration);
    }

    private CConnectionInfo convertConnectionInfo(org.sonatype.security.ldap.realms.persist.model.CConnectionInfo old) {
      final CConnectionInfo newConnectionInfo = new CConnectionInfo();
      newConnectionInfo.setAuthScheme(old.getAuthScheme());
      newConnectionInfo.setCacheTimeout(CConnectionInfo.CACHE_TIMEOUT_DEFAULT);
      newConnectionInfo.setConnectionRetryDelay(CConnectionInfo.CONNECTION_RETRY_DELAY_DEFAULT);
      newConnectionInfo.setConnectionTimeout(CConnectionInfo.CONNECTION_TIMEOUT);
      newConnectionInfo.setHost(old.getHost());
      newConnectionInfo.setPort(old.getPort());
      newConnectionInfo.setProtocol(old.getProtocol());
      newConnectionInfo.setRealm(old.getRealm());
      newConnectionInfo.setSearchBase(old.getSearchBase());
      newConnectionInfo.setSystemPassword(old.getSystemPassword());
      newConnectionInfo.setSystemUsername(old.getSystemUsername());
      return newConnectionInfo;
    }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

    CLdapServerConfiguration serverConfig = new CLdapServerConfiguration();
    serverConfig.setId(id);
    serverConfig.setName(id + "-name");

    CConnectionInfo connInfo = this.buildConnectionInfo();
    serverConfig.setConnectionInfo(connInfo);
    serverConfig.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    ldapConfigManager.addLdapServerConfiguration(serverConfig);
    CLdapServerConfiguration result = ldapConfigManager.getLdapServerConfiguration(id);
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

    CLdapServerConfiguration serverConfig = new CLdapServerConfiguration();
    serverConfig.setId(id);
    serverConfig.setName(id + "-name");

    CConnectionInfo connInfo = this.buildConnectionInfo();
    serverConfig.setConnectionInfo(connInfo);
    serverConfig.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    ldapConfigManager.addLdapServerConfiguration(serverConfig);
    ldapConfigManager.deleteLdapServerConfiguration(id);
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

    return userGroupConf;
  }

  protected CConnectionInfo buildConnectionInfo() throws UnsupportedEncodingException {
    CConnectionInfo connInfo = new CConnectionInfo();

    connInfo.setAuthScheme("ldap");
    connInfo.setBackupMirrorHost("backupHost");
    connInfo.setBackupMirrorPort(11111);
    connInfo.setBackupMirrorProtocol("ldap");
    connInfo.setCacheTimeout(30);
    connInfo.setConnectionRetryDelay(300);
    connInfo.setConnectionTimeout(15);
    connInfo.setHost("localhost");
    connInfo.setPort(386);
    connInfo.setProtocol("ldap");
    connInfo.setRealm("");
    connInfo.setSearchBase("ou=searchbase");
    connInfo.setSystemPassword(encodeBase64("systemPassword"));
    connInfo.setSystemUsername(encodeBase64("systemUsername"));

    return connInfo;
  }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CConnectionInfo

    if (ldapServer == null) {
      throw new LdapDAOException("Ldap connection is not configured.");
    }

    CConnectionInfo connInfo = ldapServer.getConnectionInfo();

    String url;
    try {
      if (useBackupUrl) {
        url = new LdapURL(connInfo.getBackupMirrorProtocol(), connInfo.getBackupMirrorHost(), connInfo
            .getBackupMirrorPort(), connInfo.getSearchBase()).toString();
      }
      else {
        url = new LdapURL(connInfo.getProtocol(), connInfo.getHost(), connInfo.getPort(), connInfo
            .getSearchBase()).toString();
      }
    }
    catch (MalformedURLException e) {
      // log an error, because the user could still log in and fix the config.
      logger.error("LDAP Configuration is Invalid.");
      throw new LdapDAOException("Invalid LDAP URL: " + e.getMessage());
    }

    defaultLdapContextFactory.setUsePooling(true);
    defaultLdapContextFactory.setUrl(url);
    defaultLdapContextFactory.setSystemUsername(connInfo.getSystemUsername());
    defaultLdapContextFactory.setSystemPassword(connInfo.getSystemPassword());
    defaultLdapContextFactory.setSearchBase(connInfo.getSearchBase());
    defaultLdapContextFactory.setAuthentication(connInfo.getAuthScheme());

    // get the timeout
    Map<String, String> connectionProperties = new HashMap<String, String>();
    connectionProperties.put("com.sun.jndi.ldap.connect.timeout",
        Integer.toString(ldapServer.getConnectionInfo().getConnectionTimeout() * 1000));

    // and the realm
    if (connInfo.getRealm() != null) {
      connectionProperties.put("java.naming.security.sasl.realm", connInfo.getRealm());
    }
    defaultLdapContextFactory.setAdditionalEnvironment(connectionProperties);

    return defaultLdapContextFactory;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.