- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中javax.security.auth.x500.X500PrivateCredential.getCertificate()
方法的一些代码示例,展示了X500PrivateCredential.getCertificate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X500PrivateCredential.getCertificate()
方法的具体详情如下:
包路径:javax.security.auth.x500.X500PrivateCredential
类名称:X500PrivateCredential
方法名:getCertificate
暂无
代码示例来源:origin: wildfly/wildfly
private static IdentityCredentials getSingleCredential(Object rawCredential) {
if (rawCredential == null) {
return IdentityCredentials.NONE;
} else if (rawCredential instanceof Credential) {
return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
} else if (rawCredential instanceof GSSCredential) {
return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
} else if (rawCredential instanceof Password) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
} else if (rawCredential instanceof X509Certificate) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
} else if (rawCredential instanceof X509Certificate[]) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
} else if (rawCredential instanceof X500PrivateCredential) {
final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
} else if (rawCredential instanceof String) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
} else if (rawCredential instanceof char[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
} else if (rawCredential instanceof byte[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
} else {
return IdentityCredentials.NONE;
}
}
代码示例来源:origin: au.net.zeus.jgdms/jgdms-rmi-tls
if (cred instanceof X500PrivateCredential) {
X500PrivateCredential xpc = (X500PrivateCredential) cred;
if (cert.equals(xpc.getCertificate())) {
result = xpc;
break;
代码示例来源:origin: au.net.zeus.jgdms/jgdms-rmi-tls
/**
* Checks if the two private credentials refer to the same principal and
* have the equivalent private key.
*/
boolean equalPrivateCredentials(X500PrivateCredential cred1,
X500PrivateCredential cred2)
{
if (cred1 == null || cred2 == null) {
return false;
}
X509Certificate cert1 = cred1.getCertificate();
X509Certificate cert2 = cred2.getCertificate();
if (cert1 == null
|| cert2 == null
|| !safeEquals(cert1.getSubjectDN(), cert2.getSubjectDN()))
{
return false;
}
/*
* I'm assuming I can depend on the equals method for private keys to
* check if the two objects represent the same key without being
* identical objects. Although that behavior isn't documented, at
* least the sun.security.pkcs.PKCS8Key class does that.
* -tjb[8.Jan.2001]
*/
PrivateKey key1 = cred1.getPrivateKey();
return key1 != null && key1.equals(cred2.getPrivateKey());
}
代码示例来源:origin: net.sf.wsag4j/wsag4j-api
new X500Principal( userCredential.getCertificate().getSubjectX500Principal().getName() );
代码示例来源:origin: com.hynnet/xws-security
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
X509Certificate x509Cert = cred.getCertificate();
BigInteger serialNo = x509Cert.getSerialNumber();
String currentIssuerName =
代码示例来源:origin: com.hynnet/xws-security
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
X509Certificate x509Cert = cred.getCertificate();
BigInteger serialNo = x509Cert.getSerialNumber();
String currentIssuerName =
代码示例来源:origin: com.hynnet/xws-security
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
X509Certificate x509Cert = cred.getCertificate();
BigInteger serialNo = x509Cert.getSerialNumber();
String currentIssuerName =
代码示例来源:origin: com.hynnet/xws-security
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
X509Certificate x509Cert = cred.getCertificate();
BigInteger serialNo = x509Cert.getSerialNumber();
String currentIssuerName =
代码示例来源:origin: stackoverflow.com
).build(
new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(creds.getPrivateKey()),
creds.getCertificate()
代码示例来源:origin: stackoverflow.com
private static void createSignature(Path srcfile, X500PrivateCredential creds, FileOutputStream target) throws Exception {
CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator() {
{
addSignerInfoGenerator(
new JcaSignerInfoGeneratorBuilder(
new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()
).build(
new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(creds.getPrivateKey()),
creds.getCertificate()
)
);
addCertificates(new JcaCertStore(new ArrayList<X509Certificate>() {
{
add(creds.getCertificate());
}
}));
}
};
try (OutputStream sigOut = gen.open(target, true)) {
Files.copy(srcfile, sigOut);
}
}
代码示例来源:origin: au.net.zeus.jgdms/jgdms-rmi-tls
X509Certificate cert = clientCredential.getCertificate();
if (getPrincipal(subject, cert) == null) {
throw new GeneralSecurityException("Missing principal");
代码示例来源:origin: stackoverflow.com
).build(
new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(creds.getPrivateKey()),
creds.getCertificate()
代码示例来源:origin: com.hynnet/xws-security
X500PrivateCredential cred = (X500PrivateCredential)it.next();
if (matchesKeyIdentifier(Base64.decode(keyIdentifier),
cred.getCertificate()))
return cred.getPrivateKey();
代码示例来源:origin: au.net.zeus.jgdms/jgdms-rmi-tls
for (int i = readOnlyPrivateCredentials.length; --i >= 0; ) {
X500PrivateCredential xpc = readOnlyPrivateCredentials[i];
if (cert.equals(xpc.getCertificate())) {
return xpc;
代码示例来源:origin: com.hynnet/xws-security
public PrivateKey getPrivateKey(Map context, byte[] keyIdentifier)
throws XWSSecurityException {
/*
use PrivateKeyCallback
*/
try {
Subject subject = getSubject(context);
if (subject != null) {
Set set = subject.getPrivateCredentials(X500PrivateCredential.class);
if (set != null) {
Iterator it = set.iterator();
while (it.hasNext()) {
X500PrivateCredential cred = (X500PrivateCredential)it.next();
if (matchesKeyIdentifier(Base64.decode(keyIdentifier),
cred.getCertificate()))
return cred.getPrivateKey();
}
}
}
PrivateKeyCallback.Request request = new PrivateKeyCallback.SubjectKeyIDRequest(
keyIdentifier);
PrivateKeyCallback pkCallback = new PrivateKeyCallback(request);
Callback[] callbacks = new Callback[] { pkCallback };
_handler.handle(callbacks);
return pkCallback.getKey();
} catch (Exception e) {
throw new XWSSecurityException(e);
}
}
代码示例来源:origin: com.hynnet/xws-security
X500PrivateCredential cred = (X500PrivateCredential)it.next();
if (matchesThumbPrint(Base64.decode(keyIdentifier),
cred.getCertificate()))
return cred.getPrivateKey();
代码示例来源:origin: au.net.zeus.jgdms/jgdms-rmi-tls
throw new SecurityException("Missing subject");
X509Certificate cert = cred.getCertificate();
if (getPrincipal(subject, cert) == null) {
throw new SecurityException("Missing principal");
代码示例来源:origin: com.hynnet/xws-security
X500PrivateCredential cred = (X500PrivateCredential)it.next();
if (matchesThumbPrint(Base64.decode(keyIdentifier),
cred.getCertificate()))
return cred.getPrivateKey();
代码示例来源:origin: org.jboss.eap/wildfly-client-all
private static IdentityCredentials getSingleCredential(Object rawCredential) {
if (rawCredential == null) {
return IdentityCredentials.NONE;
} else if (rawCredential instanceof Credential) {
return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
} else if (rawCredential instanceof GSSCredential) {
return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
} else if (rawCredential instanceof Password) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
} else if (rawCredential instanceof X509Certificate) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
} else if (rawCredential instanceof X509Certificate[]) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
} else if (rawCredential instanceof X500PrivateCredential) {
final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
} else if (rawCredential instanceof String) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
} else if (rawCredential instanceof char[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
} else if (rawCredential instanceof byte[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
} else {
return IdentityCredentials.NONE;
}
}
代码示例来源:origin: org.wildfly/wildfly-naming-client
private static IdentityCredentials getSingleCredential(Object rawCredential) {
if (rawCredential == null) {
return IdentityCredentials.NONE;
} else if (rawCredential instanceof Credential) {
return IdentityCredentials.NONE.withCredential((Credential) rawCredential);
} else if (rawCredential instanceof GSSCredential) {
return IdentityCredentials.NONE.withCredential(new GSSKerberosCredential((GSSCredential) rawCredential));
} else if (rawCredential instanceof Password) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential((Password) rawCredential));
} else if (rawCredential instanceof X509Certificate) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate) rawCredential));
} else if (rawCredential instanceof X509Certificate[]) {
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPublicCredential((X509Certificate[]) rawCredential));
} else if (rawCredential instanceof X500PrivateCredential) {
final X500PrivateCredential credential = (X500PrivateCredential) rawCredential;
return IdentityCredentials.NONE.withCredential(new X509CertificateChainPrivateCredential(credential.getPrivateKey(), credential.getCertificate()));
} else if (rawCredential instanceof String) {
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((String) rawCredential).toCharArray())));
} else if (rawCredential instanceof char[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, (char[]) rawCredential)));
} else if (rawCredential instanceof byte[]) {
// todo: automatically decode to other credential types
return IdentityCredentials.NONE.withCredential(new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, new String((byte[]) rawCredential, StandardCharsets.UTF_8).toCharArray())));
} else {
return IdentityCredentials.NONE;
}
}
我是一名优秀的程序员,十分优秀!