本文整理汇总了Java中org.globus.gsi.CertUtil.loadCertificate方法的典型用法代码示例。如果您正苦于以下问题:Java CertUtil.loadCertificate方法的具体用法?Java CertUtil.loadCertificate怎么用?Java CertUtil.loadCertificate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.globus.gsi.CertUtil
的用法示例。
在下文中一共展示了CertUtil.loadCertificate方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProxy
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public GlobusCredential createProxy(String pwd)
throws Exception {
getProperties();
userCert = CertUtil.loadCertificate(props.getUserCertFile());
OpenSSLKey key =
new BouncyCastleOpenSSLKey(props.getUserKeyFile());
if (key.isEncrypted()) {
try {
key.decrypt(pwd);
} catch(GeneralSecurityException e) {
throw new Exception("Wrong password or other security error");
}
}
PrivateKey userKey = key.getPrivateKey();
BouncyCastleCertProcessingFactory factory =
BouncyCastleCertProcessingFactory.getDefault();
int proxyType = (getLimited()) ?
GSIConstants.DELEGATION_LIMITED :
GSIConstants.DELEGATION_FULL;
return factory.createCredential(new X509Certificate[] {userCert},
userKey,
props.getProxyStrength(),
props.getProxyLifeTime() * 3600,
proxyType,
(X509ExtensionSet)null);
}
示例2: loadCert
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public void loadCert(String certFile) {
try {
X509Certificate cert = CertUtil.loadCertificate(certFile);
certificates.addElement(new CertInfo(cert, certFile));
} catch(Exception e) {
}
}
示例3: getCertificate
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
private X509Certificate getCertificate(int i) throws Exception {
ClassLoader loader = ProxyPathValidatorTest.class.getClassLoader();
String name = ProxyPathValidatorTest.BASE + ProxyPathValidatorTest.certs[i][1];
InputStream in = loader.getResourceAsStream(name);
if (in == null) {
throw new Exception("Unable to load: " + name);
}
return CertUtil.loadCertificate(in);
}
示例4: testGetCertificateType2
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public void testGetCertificateType2() throws Exception {
for (int i=0;i<badCerts.length;i++) {
X509Certificate cert = CertUtil.loadCertificate(new ByteArrayInputStream(badCerts[i].getBytes()));
try {
BouncyCastleUtil.getCertificateType(cert);
fail("proxy verification did not fail as expected");
} catch (CertificateException e) {
e.printStackTrace();
// ignore
}
}
}
示例5: initCerts
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public static X509Certificate[] initCerts() throws Exception {
X509Certificate [] goodCertsArr = new X509Certificate[certs.length];
ClassLoader loader = ProxyPathValidatorTest.class.getClassLoader();
for (int i=0;i<certs.length;i++) {
String name = BASE + certs[i][1];
InputStream in = loader.getResourceAsStream(name);
if (in == null) {
throw new Exception("Unable to load: " + name);
}
goodCertsArr[i] = CertUtil.loadCertificate(in);
}
return goodCertsArr;
}
示例6: testKeyUsage
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public void testKeyUsage() throws Exception {
X509Certificate [] certsArr = new X509Certificate[testCerts.length];
for (int i=0;i<certsArr.length;i++) {
certsArr[i] =
CertUtil.loadCertificate(new ByteArrayInputStream(testCerts[i].getBytes()));
}
X509Certificate [] chain = null;
// certArr[1] - has key usage but certSign is off - but it sings proxy
// certArr[2] - has key usage and certSing is on
chain = new X509Certificate[] {certsArr[0], certsArr[1], certsArr[2]};
validateChain(chain, certsArr[1], false);
}
示例7: start
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
public void start() {
try {
X509Certificate cert = CertUtil.loadCertificate(userCertFile);
boolean globusStyle = false;
String dn = null;
if (globusStyle) {
dn = CertUtil.toGlobusID(cert.getSubjectDN().getName());
} else {
dn = cert.getSubjectDN().getName();
}
appendToStatus("subject : " + dn);
dn = null;
if (globusStyle) {
dn = CertUtil.toGlobusID(cert.getIssuerDN().getName());
} else {
dn = cert.getIssuerDN().getName();
}
appendToStatus("issuer : " + dn);
TimeZone tz = null;
DateFormat df = null;
if (globusStyle) {
tz = TimeZone.getTimeZone("GMT");
df = new SimpleDateFormat("MMM dd HH:mm:ss yyyy z");
df.setTimeZone(tz);
}
String dt = null;
if (globusStyle) {
dt = df.format(cert.getNotBefore());
} else {
dt = cert.getNotBefore().toString();
}
appendToStatus("start date : " + dt);
dt = null;
if (globusStyle) {
dt = df.format(cert.getNotAfter());
} else {
dt = cert.getNotAfter().toString();
}
appendToStatus("end date : " + dt);
appendToStatus("certificate :");
appendToStatus(cert.toString());
} catch (Exception ex) {
// Write exection to Java console.
ex.printStackTrace();
// Write exception to status area.
String message = ex.getMessage() + "\n";
StackTraceElement[] stackElements = ex.getStackTrace();
for (int i = 0; i < stackElements.length; i++) {
message += stackElements[i].toString() + "\n";
}
appendToStatus(message);
}
}
示例8: loadCertificates
import org.globus.gsi.CertUtil; //导入方法依赖的package包/类
/**
* Load certificates.
*
* @param path the path
*
* @throws GeneralSecurityException the general security exception
* @throws IOException Signals that an I/O exception has occurred.
*/
private void loadCertificates(String path) throws GeneralSecurityException, IOException {
// certificates = CertUtil.loadCertificates(arg);
certificates = new X509Certificate[] { CertUtil.loadCertificate(path) };
}