9

AD サーバーを 1 つだけ構成する必要がある場合は、Active Directory に対して認証できます。ソリューションは 、ssl を介した匿名ユーザーとしての Active Directory 認証として提供されます。

Load Balancer の背後で複数の AD が実行されていると、スタックします。

間にロード バランサーがあるため、ホスト名のみを取得し、可用性に基づいてロード バランサーの背後にあるホスト名に AD の IP を置き換えます。したがって、認証要求を処理するためにどの Active Directory サーバーが使用されるかを知ることはできません。そのため、事前に証明書を生成することはできません。また、クライアントが負荷分散に使用している AD の IP を取得できません (セキュリティ上の理由から)。したがって、 jssecacertを生成する意味はありません。私がする必要があるのは、証明書の検証を無効にすることだけです。LdapTemplateクラス ( spring -ldap 1.3.1 を使用) を使用してユーザーを認証しています。私の春の設定は次のようになります...

<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
    <property name="contextSource" ref="contextSource" />
     <property name="ignorePartialResultException" value="yes" />
</bean>
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
    <property name="url" value="ldaps://xxx.xxx.xxx.xxx:636" />
</bean>

認証方法:

public boolean login(String username, String password) {

    System.setProperty("javax.net.ssl.trustStore",
            .../jssecacerts");

    boolean authenticate=false;

    AndFilter filter = new AndFilter();
    filter.and(new EqualsFilter("xyz","xyz"));
    filter.and(new EqualsFilter("xyz", xyz));

    authenticate = this.ldapTemplate.authenticate(base, filter.encode(), password); 
    return authenticate;

    }

証明書を持っている必要がないので、必要ありませんSystem.setProperty("javax.net.ssl.trustStore", .../jssecacerts");

証明書の検証を無効にするために必要な変更。

私はLDAPのことでかなり新しいです。、適切な回答をお願いします。

4

1 に答える 1

14

まあ、ssl証明書を気にしないトリッキーなソリューションを提供してくれたDarren Haugeに感謝します。ここでソリューションを書き換えます:

public static void trustSelfSignedSSL() {
    try {
        SSLContext ctx = SSLContext.getInstance("TLS");
        X509TrustManager tm = new X509TrustManager() {

            public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException {
            }

            public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {
            }

            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }
        };
        ctx.init(null, new TrustManager[]{tm}, null);
        SSLContext.setDefault(ctx);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

ユーティリティ クラスを作成し、その中にこのメソッドを配置するだけです。必要な場所でこのメソッドを呼び出します。

このソリューションに関するコメントは大歓迎です。

ありがとう。

于 2013-06-20T04:57:31.097 に答える