本文整理汇总了Java中org.globus.gsi.GlobusCredential.getCertificateChain方法的典型用法代码示例。如果您正苦于以下问题:Java GlobusCredential.getCertificateChain方法的具体用法?Java GlobusCredential.getCertificateChain怎么用?Java GlobusCredential.getCertificateChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.globus.gsi.GlobusCredential
的用法示例。
在下文中一共展示了GlobusCredential.getCertificateChain方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCredential
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
/**
* Sets the credential.
*
* @param cred the credential
* @exception GeneralSecurityException in case of an error
*/
public void setCredential(GlobusCredential cred)
throws GeneralSecurityException {
X509Certificate [] certs = cred.getCertificateChain();
Vector v = new Vector(certs.length);
for (int i=certs.length-1;i>=0;i--) {
v.addElement(certs[i].getEncoded());
}
setCertificateChain(v);
setPrivateKey(convertPrivateKey(cred.getPrivateKey()));
try {
setPublicKeyFromCert(certs[0].getEncoded());
} catch (IOException e) {
throw new ChainedGeneralSecurityException("", e);
}
}
示例2: handleCredentialSelection
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void handleCredentialSelection() {
int maxPathLength = 0;
long lifetimeSeconds = 0;
try {
GlobusCredential cred = getProxy().getSelectedCredential().getCredential();
X509Certificate[] certs = cred.getCertificateChain();
maxPathLength = getDelegationPathLength(certs[0]);
lifetimeSeconds = cred.getTimeLeft() - SECONDS_OFFSET;
} catch (Exception e) {
FaultUtil.logFault(log, e);
}
if (maxPathLength < 0) {
maxPathLength = 0;
}
delegatedCredentialPathLength.removeAllItems();
for (int i = 0; i <= maxPathLength; i++) {
delegatedCredentialPathLength.addItem(new Integer(i));
}
if (maxPathLength >= 1) {
delegatedCredentialPathLength.setSelectedIndex(1);
}
getDelegationLifetime().setLifetime(lifetimeSeconds);
getIssuedCredentialLifetime().setLifetime(lifetimeSeconds - SECONDS_OFFSET);
}
示例3: encode
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public static X509CredentialDescriptor encode(GlobusCredential cred,
X509CredentialDescriptor des) throws Exception {
des.setIdentity(cred.getIdentity());
EncodedCertificates list = new EncodedCertificates();
X509Certificate[] chain = cred.getCertificateChain();
if (chain != null) {
List<String> certs = new ArrayList<String>(chain.length);
for (int i = 0; i < chain.length; i++) {
certs.add(CertUtil.writeCertificate(chain[i]));
}
list.getEncodedCertificate().addAll(certs);
}
des.setEncodedCertificates(list);
des.setEncodedKey(KeyUtil.writePrivateKey(cred.getPrivateKey(),
(String) null));
return des;
}
示例4: generateNewCredential
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
private GlobusCredential generateNewCredential(Key key) throws GlobusCredentialException,
InvalidSecurityContextException, GeneralSecurityException {
GlobusCredential src = GlobusCredential.getDefaultCredential();
if (src == null) {
throw new InvalidSecurityContextException("No default credential found");
}
// If only the security stuff in [email protected] would be
// separable from the WS crap
BouncyCastleCertProcessingFactory factory =
BouncyCastleCertProcessingFactory.getDefault();
int delegType = (key.delegationType == Delegation.FULL_DELEGATION ?
GSIConstants.DELEGATION_FULL : GSIConstants.DELEGATION_LIMITED);
KeyPair newKeyPair = CertUtil.generateKeyPair("RSA", src.getStrength());
X509Certificate[] srcChain = src.getCertificateChain();
X509Certificate newCert = null;
try {
newCert = factory.createProxyCertificate(srcChain[0],
src.getPrivateKey(),
newKeyPair.getPublic(), -1,
key.delegationType == Delegation.FULL_DELEGATION ?
GSIConstants.DELEGATION_FULL
: GSIConstants.DELEGATION_LIMITED,
(X509ExtensionSet) null, null);
}
catch (GeneralSecurityException e) {
throw new InvalidSecurityContextException("Delegation failed", e);
}
X509Certificate[] newChain = new X509Certificate[srcChain.length + 1];
newChain[0] = newCert;
System.arraycopy(srcChain, 0, newChain, 1, srcChain.length);
return new GlobusCredential(newKeyPair.getPrivate(), newChain);
}
示例5: testExtensions
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void testExtensions() throws Exception {
GlobusCredential cred = GlobusCredential.getDefaultCredential();
X509Extension ext = null;
String oid1 = "1.2.3.4";
String expectedValue1 = "foo";
boolean critical1 = false;
String oid2 = "5.6.7.8";
String expectedValue2 = "bar";
boolean critical2 = true;
X509ExtensionSet extSet = new X509ExtensionSet();
ext = new X509Extension(oid1, critical1, expectedValue1.getBytes());
extSet.add(ext);
ext = new X509Extension(oid2, critical2, expectedValue2.getBytes());
extSet.add(ext);
GlobusCredential newCred =
factory.createCredential(cred.getCertificateChain(),
cred.getPrivateKey(),
512,
60 * 60,
GSIConstants.GSI_3_IMPERSONATION_PROXY,
extSet,
null);
X509Certificate newCert = newCred.getCertificateChain()[0];
System.out.println(newCert);
verifyExtension(newCert, oid1, expectedValue1, critical1);
verifyExtension(newCert, oid2, expectedValue2, critical2);
}
示例6: printCredential
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public static void printCredential(GlobusCredential plainProxy, PrintStream out)
{
// PrivateKey privateKey = plainProxy.getPrivateKey();
X509Certificate[] certChain = plainProxy.getCertificateChain();
for (int i = 0; i < certChain.length; i++)
{
out.printf("--- Certificate [%d] ---\n", i);
out.printf("%s\n", certChain[i].toString());
}
}
示例7: validate
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public boolean validate(GlobusCredential globusCredential)
throws AuthenticationConfigurationException {
verifyCredentials(globusCredential);
X509Certificate[] proxyChain = globusCredential.getCertificateChain();
X509Certificate[] trustedCerts = loadTrustedCerts();
CertificateRevocationLists crls = loadCertificateRevocationLists();
validaeProxy(proxyChain, trustedCerts, crls);
return true;
}
示例8: encode
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public static X509CredentialDescriptor encode(GlobusCredential cred, X509CredentialDescriptor des) throws Exception {
des.setIdentity(cred.getIdentity());
EncodedCertificates list = new EncodedCertificates();
X509Certificate[] chain = cred.getCertificateChain();
if (chain != null) {
String[] certs = new String[chain.length];
for (int i = 0; i < chain.length; i++) {
certs[i] = CertUtil.writeCertificate(chain[i]);
}
list.setEncodedCertificate(certs);
}
des.setEncodedCertificates(list);
des.setEncodedKey(KeyUtil.writePrivateKey(cred.getPrivateKey(), (String) null));
return des;
}
示例9: showCredential
import org.globus.gsi.GlobusCredential; //导入方法依赖的package包/类
public void showCredential(GlobusCredential cred) {
clearCredential();
subjectField.setText(cred.getSubject());
issuer.setText(cred.getIssuer());
identity.setText(cred.getIdentity());
strength.setText(cred.getStrength() + " bits");
cred.getTimeLeft();
GregorianCalendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int) cred.getTimeLeft());
timeLeft.setText(c.getTime().toString());
X509Certificate[] certs = cred.getCertificateChain();
for (int i = 0; i < certs.length; i++) {
certificates.addCertificate(certs[i]);
}
}