本文整理汇总了Java中org.bouncycastle.jce.provider.X509CertParser.engineRead方法的典型用法代码示例。如果您正苦于以下问题:Java X509CertParser.engineRead方法的具体用法?Java X509CertParser.engineRead怎么用?Java X509CertParser.engineRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.jce.provider.X509CertParser
的用法示例。
在下文中一共展示了X509CertParser.engineRead方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
public static X509CertificateWrapper parse(final RpslObject rpslObject) {
if (!looksLikeX509Key(rpslObject)) {
throw new IllegalArgumentException("The supplied object has no key");
}
try {
final byte[] bytes = RpslObjectFilter.getCertificateFromKeyCert(rpslObject).getBytes(Charsets.ISO_8859_1);
X509CertParser parser = new X509CertParser();
parser.engineInit(new ByteArrayInputStream(bytes));
X509Certificate result = (X509Certificate) parser.engineRead();
if (result == null) {
throw new IllegalArgumentException("Invalid X509 Certificate");
}
return new X509CertificateWrapper(result);
} catch (StreamParsingException e) {
throw new IllegalArgumentException("Error parsing X509 certificate from key-cert object", e);
}
}
示例2: getEncryptionCredential
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private Credential getEncryptionCredential(final WsFederationConfiguration config) {
try {
// This will need to contain the private keypair in PEM format
final BufferedReader br = new BufferedReader(new InputStreamReader(config.getEncryptionPrivateKey().getInputStream()));
Security.addProvider(new BouncyCastleProvider());
final PEMParser pemParser = new PEMParser(br);
final Object privateKeyPemObject = pemParser.readObject();
final JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());
final KeyPair kp;
if (privateKeyPemObject instanceof PEMEncryptedKeyPair) {
final PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
final PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder()
.build(config.getEncryptionPrivateKeyPassword().toCharArray());
kp = converter.getKeyPair(ckp.decryptKeyPair(decProv));
} else {
kp = converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
}
final X509CertParser certParser = new X509CertParser();
// This is the certificate shared with ADFS in DER format, i.e certificate.crt
certParser.engineInit(config.getEncryptionCertificate().getInputStream());
final X509CertificateObject cert = (X509CertificateObject) certParser.engineRead();
return new BasicX509Credential(cert, kp.getPrivate());
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例3: createCerts
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private Set createCerts(List list, X509CertStoreSelector xselector)
throws StoreException
{
Set certSet = new HashSet();
Iterator it = list.iterator();
X509CertParser parser = new X509CertParser();
while (it.hasNext())
{
try
{
parser.engineInit(new ByteArrayInputStream((byte[])it
.next()));
X509Certificate cert = (X509Certificate)parser
.engineRead();
if (xselector.match((Object)cert))
{
certSet.add(cert);
}
}
catch (Exception e)
{
}
}
return certSet;
}
示例4: extractCertificate
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private X509Certificate extractCertificate(final String[] domains, InputStream inputStream)
throws StreamParsingException {
X509CertParser certParser = new X509CertParser();
certParser.engineInit(inputStream);
X509Certificate certificate = (X509Certificate) certParser.engineRead();
certificateStorage.saveCertificate(domains, certificate);
return certificate;
}
示例5: apply
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
@Override
public Object apply(Object input) {
if (input instanceof String && input.toString().contains("BEGIN CERTIFICATE")) {
try {
X509CertParser x509CertParser = new X509CertParser();
x509CertParser.engineInit(new ByteArrayInputStream(input.toString().getBytes()));
return x509CertParser.engineRead();
} catch (Exception ex) {
return input;
}
}
return input;
}
示例6: getEncryptionCredential
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private static Credential getEncryptionCredential(final WsFederationConfiguration config) {
try {
// This will need to contain the private keypair in PEM format
LOGGER.debug("Locating encryption credential private key [{}]", config.getEncryptionPrivateKey());
final BufferedReader br = new BufferedReader(new InputStreamReader(
config.getEncryptionPrivateKey().getInputStream(), StandardCharsets.UTF_8));
Security.addProvider(new BouncyCastleProvider());
LOGGER.debug("Parsing credential private key");
final PEMParser pemParser = new PEMParser(br);
final Object privateKeyPemObject = pemParser.readObject();
final JcaPEMKeyConverter converter = new JcaPEMKeyConverter().setProvider(new BouncyCastleProvider());
final KeyPair kp;
if (privateKeyPemObject instanceof PEMEncryptedKeyPair) {
LOGGER.debug("Encryption private key is an encrypted keypair");
final PEMEncryptedKeyPair ckp = (PEMEncryptedKeyPair) privateKeyPemObject;
final PEMDecryptorProvider decProv = new JcePEMDecryptorProviderBuilder()
.build(config.getEncryptionPrivateKeyPassword().toCharArray());
LOGGER.debug("Attempting to decrypt the encrypted keypair based on the provided encryption private key password");
kp = converter.getKeyPair(ckp.decryptKeyPair(decProv));
} else {
LOGGER.debug("Extracting a keypair from the private key");
kp = converter.getKeyPair((PEMKeyPair) privateKeyPemObject);
}
final X509CertParser certParser = new X509CertParser();
// This is the certificate shared with ADFS in DER format, i.e certificate.crt
LOGGER.debug("Locating encryption certificate [{}]", config.getEncryptionCertificate());
certParser.engineInit(config.getEncryptionCertificate().getInputStream());
LOGGER.debug("Invoking certificate engine to parse the certificate [{}]", config.getEncryptionCertificate());
final X509CertificateObject cert = (X509CertificateObject) certParser.engineRead();
LOGGER.debug("Creating final credential based on the certificate [{}] and the private key", cert.getIssuerDN());
return new BasicX509Credential(cert, kp.getPrivate());
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例7: getCertificate
import org.bouncycastle.jce.provider.X509CertParser; //导入方法依赖的package包/类
private X509Certificate getCertificate(String certificate) throws StreamParsingException {
X509CertParser parser = new X509CertParser();
parser.engineInit(new ByteArrayInputStream(certificate.getBytes()));
return (X509Certificate) parser.engineRead();
}