Skip to content
Snippets Groups Projects
Commit 3477988f authored by Dustin Jenkins's avatar Dustin Jenkins
Browse files

Merge branch 's1668' of /srv/cadc/git/wopencadc into s1711

parents cec1067f a0efe6ae
No related branches found
No related tags found
No related merge requests found
...@@ -122,7 +122,8 @@ public class GMSClient ...@@ -122,7 +122,8 @@ public class GMSClient
private static final Logger log = Logger.getLogger(GMSClient.class); private static final Logger log = Logger.getLogger(GMSClient.class);
// socket factory to use when connecting // socket factory to use when connecting
public SSLSocketFactory sslSocketFactory; private SSLSocketFactory sslSocketFactory;
private SSLSocketFactory mySocketFactory;
private String baseURL; private String baseURL;
...@@ -1028,24 +1029,41 @@ public class GMSClient ...@@ -1028,24 +1029,41 @@ public class GMSClient
*/ */
public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory)
{ {
if (mySocketFactory != null)
throw new IllegalStateException("Illegal use of GMSClient: "
+ "cannot set SSLSocketFactory after using one created from Subject");
this.sslSocketFactory = sslSocketFactory; this.sslSocketFactory = sslSocketFactory;
clearCache(); clearCache();
} }
/** private int subjectHashCode = 0;
* @return the sslSocketFactory
*/
private SSLSocketFactory getSSLSocketFactory() private SSLSocketFactory getSSLSocketFactory()
{ {
if (this.sslSocketFactory == null) AccessControlContext ac = AccessController.getContext();
Subject s = Subject.getSubject(ac);
// no real Subject: can only use the one from setSSLSocketFactory
if (s == null || s.getPrincipals().isEmpty())
{
return sslSocketFactory;
}
// lazy init
if (this.mySocketFactory == null)
{
log.debug("getSSLSocketFactory: " + s);
this.mySocketFactory = SSLUtil.getSocketFactory(s);
this.subjectHashCode = s.hashCode();
}
else
{ {
log.debug("initHTTPS: lazy init"); int c = s.hashCode();
AccessControlContext ac = AccessController.getContext(); if (c != subjectHashCode)
Subject s = Subject.getSubject(ac); throw new IllegalStateException("Illegal use of "
this.sslSocketFactory = SSLUtil.getSocketFactory(s); + this.getClass().getSimpleName()
log.debug("Socket Factory: " + this.sslSocketFactory); + ": subject change not supported for internal SSLSocketFactory");
} }
return this.sslSocketFactory; return this.mySocketFactory;
} }
protected void clearCache() protected void clearCache()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment