use of edu.uiuc.ncsa.security.util.ssl.MyTrustManager in project OA4MP by ncsa.
the class LDAPSSLSocketFactory method getSF.
protected SSLSocketFactory getSF() throws GeneralSecurityException, IOException {
SSLContext sc = SSLContext.getInstance("SSL");
MyTrustManager mtm = new MyTrustManager(null, getSslConfiguration());
mtm.setHost(getLdapConfiguration().getServer());
TrustManager[] trustAllCerts = new TrustManager[] { mtm };
sc.init(getKeyManagerFactory().getKeyManagers(), trustAllCerts, new java.security.SecureRandom());
SSLSocketFactory sf = sc.getSocketFactory();
// this.socket = (SSLSocket) sf.createSocket(this.hostLookup(), this.port);
return sf;
}
use of edu.uiuc.ncsa.security.util.ssl.MyTrustManager in project OA4MP by ncsa.
the class MyProxyLogon method connect.
/**
* Connects to the MyProxy server at the desired host and port. Requires
* host authentication via SSL. The host's certificate subject must
* match the requested hostname. If CA certificates are found in the
* standard GSI locations, they will be used to verify the server's
* certificate. If trust roots are requested and no CA certificates are
* found, the server's certificate will still be accepted.
*/
public void connect() throws IOException, GeneralSecurityException {
try {
SSLContext sc = SSLContext.getInstance("SSL");
MyTrustManager mtm = new MyTrustManager(getMlf(), getExistingTrustRootPath(), getServerDN());
mtm.setHost(hostLookup());
TrustManager[] trustAllCerts = new TrustManager[] { mtm };
sc.init(getKeyManagers(), trustAllCerts, new java.security.SecureRandom());
SSLSocketFactory sf = sc.getSocketFactory();
this.socket = (SSLSocket) sf.createSocket(this.hostLookup(), this.port);
if (0 < getSocketTimeout()) {
// NOTE that this is an integer that is used for milliseconds.
socket.setSoTimeout((int) getSocketTimeout());
socket.setKeepAlive(true);
}
this.socket.startHandshake();
this.socketIn = new BufferedInputStream(this.socket.getInputStream());
this.socketOut = new BufferedOutputStream(this.socket.getOutputStream());
this.state = State.CONNECTED;
} catch (Throwable t) {
handleException(t, getClass().getSimpleName() + " could not connect to the server, socket " + (this.socket == null ? "" : "not") + " created.");
}
}
Aggregations