List of usage examples for org.bouncycastle.jce.provider X509CertificateObject getSubjectDN
public Principal getSubjectDN()
From source file:org.glite.slcs.caclient.impl.CMPResponse.java
License:Apache License
public Certificate getCertificate(Principal principal) throws CMPException, SLCSException { CertRepMessage certRepMessage = this.pkiMessage.getBody().getCp(); // Get the first message in the chain CertResponse certResp = certRepMessage.getResponse(0); if (certResp == null) { log.error("No certificates found from the response!"); return null; }//from w w w . j ava2s.com X509CertificateStructure certSt = certResp.getCertifiedKeyPair().getCertOrEncCert().getCertificate(); X509CertificateObject certObject = null; try { // generate the certificate object certObject = new X509CertificateObject(certSt); } catch (Exception e) { log.error("Error while creating certObject: " + e); throw new CMPException(e); } if (certObject.getSubjectDN().equals(principal)) { log.info("The certificate subject matched with the requested one."); X509Certificate cert = (X509Certificate) certObject; try { return new Certificate(cert); } catch (GeneralSecurityException e) { throw new SLCSException(e); } } else { log.warn("The certificate subject did NOT match with the requested one!"); return null; } }