| 1 |
/* |
| 2 |
* Copyright 1999-2010 University of Chicago |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in |
| 5 |
* compliance with the License. You may obtain a copy of the License at |
| 6 |
* |
| 7 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
* |
| 9 |
* Unless required by applicable law or agreed to in writing, software distributed under the License is |
| 10 |
* distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 11 |
* express or implied. |
| 12 |
* |
| 13 |
* See the License for the specific language governing permissions and limitations under the License. |
| 14 |
*/ |
| 15 |
package org.globus.gsi.gssapi.net; |
| 16 |
|
| 17 |
import java.net.Socket; |
| 18 |
import java.io.IOException; |
| 19 |
|
| 20 |
import org.ietf.jgss.GSSContext; |
| 21 |
|
| 22 |
public abstract class GssSocketFactory { |
| 23 |
|
| 24 |
private static GssSocketFactory factory = null; |
| 25 |
|
| 26 |
public synchronized static GssSocketFactory getDefault() { |
| 27 |
if (factory == null) { |
| 28 |
String className = System.getProperty("org.globus.gsi.gssapi.net.provider"); |
| 29 |
if (className == null) { |
| 30 |
className = "org.globus.gsi.gssapi.net.impl.GSIGssSocketFactory"; |
| 31 |
} |
| 32 |
try { |
| 33 |
Class clazz = Class.forName(className); |
| 34 |
if (!GssSocketFactory.class.isAssignableFrom(clazz)) { |
| 35 |
throw new RuntimeException("Invalid GssSocketFactory provider class"); |
| 36 |
} |
| 37 |
factory = (GssSocketFactory)clazz.newInstance(); |
| 38 |
} catch (ClassNotFoundException e) { |
| 39 |
throw new RuntimeException("Unable to load '" + className + "' class: " + |
| 40 |
e.getMessage()); |
| 41 |
} catch (InstantiationException e) { |
| 42 |
throw new RuntimeException("Unable to instantiate '" + className + "' class: " + |
| 43 |
e.getMessage()); |
| 44 |
} catch (IllegalAccessException e) { |
| 45 |
throw new RuntimeException("Unable to instantiate '" + className + "' class: " + |
| 46 |
e.getMessage()); |
| 47 |
} |
| 48 |
} |
| 49 |
return factory; |
| 50 |
} |
| 51 |
|
| 52 |
public abstract Socket createSocket(Socket s, |
| 53 |
String host, |
| 54 |
int port, |
| 55 |
GSSContext context); |
| 56 |
|
| 57 |
public abstract Socket createSocket(String host, |
| 58 |
int port, |
| 59 |
GSSContext context) |
| 60 |
throws IOException; |
| 61 |
|
| 62 |
} |