| 1 |
package org.globus.gsi; |
| 2 |
|
| 3 |
import org.globus.gsi.stores.ResourceCertStoreParameters; |
| 4 |
import org.globus.gsi.stores.Stores; |
| 5 |
|
| 6 |
import org.globus.gsi.provider.GlobusProvider; |
| 7 |
|
| 8 |
import org.globus.gsi.provider.simple.SimpleMemoryCertStoreParams; |
| 9 |
import org.globus.gsi.provider.simple.SimpleMemoryProvider; |
| 10 |
|
| 11 |
import java.security.cert.CertStore; |
| 12 |
|
| 13 |
import org.globus.common.CoGProperties; |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
import java.security.Security; |
| 18 |
|
| 19 |
/** |
| 20 |
* This is a helper class to create convert TrustCertificates |
| 21 |
* @deprecated |
| 22 |
*/ |
| 23 |
public class TrustedCertificatesUtil { |
| 24 |
|
| 25 |
static { |
| 26 |
Security.addProvider(new GlobusProvider()); |
| 27 |
Security.addProvider(new SimpleMemoryProvider()); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Create a CertStore object from TrustedCertificates. |
| 32 |
* The store only loads trusted certificates, no signing policies |
| 33 |
*/ |
| 34 |
public static CertStore createCertStore(TrustedCertificates tc) throws Exception { |
| 35 |
|
| 36 |
CertStore store = null; |
| 37 |
if (tc == null) { |
| 38 |
String caCertPattern = "file:" + CoGProperties.getDefault().getCaCertLocations() + "/*.0"; |
| 39 |
store = Stores.getCACertStore(caCertPattern); |
| 40 |
} else { |
| 41 |
SimpleMemoryCertStoreParams params = new SimpleMemoryCertStoreParams(tc.getCertificates(), null); |
| 42 |
params.setCerts(tc.getCertificates()); |
| 43 |
store = CertStore.getInstance(SimpleMemoryProvider.CERTSTORE_TYPE, params, SimpleMemoryProvider.PROVIDER_NAME); |
| 44 |
} |
| 45 |
return store; |
| 46 |
} |
| 47 |
} |