mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
04.49.2009 9fdb95ca9c3c8e3524845760b81a85c7a4c81a45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.sun.opends.sdk.util;
 
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
 
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
 
/**
 * Created by IntelliJ IDEA.
 * User: boli
 * Date: Oct 22, 2009
 * Time: 3:10:13 PM
 * To change this template use File | Settings | File Templates.
 */
public class SSLUtils
{
  public static SSLContext getSSLContext(TrustManager trustManager,
                                         KeyManager keyManager)
      throws KeyManagementException, NoSuchAlgorithmException {
    TrustManager[] tm = null;
    if (trustManager != null)
    {
      tm = new TrustManager[] {trustManager};
    }
 
    KeyManager[] km = null;
    if (keyManager != null)
    {
      km = new KeyManager[] {keyManager};
    }
 
    SSLContext sslContext = SSLContext.getInstance("TLSv1");
    sslContext.init(km, tm, null);
 
    return sslContext;
  }
}