List of usage examples for org.bouncycastle.asn1.icao LDSSecurityObject getInstance
public static LDSSecurityObject getInstance(Object obj)
From source file:org.jmrtd.lds.SODFile.java
License:Open Source License
/** * Reads the security object (containing the hashes * of the data groups) found in the SignedData field. * * @return the security object//from ww w.j a va 2 s . c o m * * @throws IOException */ private static LDSSecurityObject getLDSSecurityObject(SignedData signedData) { try { ContentInfo encapContentInfo = signedData.getEncapContentInfo(); String contentType = encapContentInfo.getContentType().getId(); DEROctetString eContent = (DEROctetString) encapContentInfo.getContent(); if (!(ICAO_LDS_SOD_OID.equals(contentType) || SDU_LDS_SOD_OID.equals(contentType) || ICAO_LDS_SOD_ALT_OID.equals(contentType))) { LOGGER.warning("SignedData does not appear to contain an LDS SOd. (content type is " + contentType + ", was expecting " + ICAO_LDS_SOD_OID + ")"); } ASN1InputStream inputStream = new ASN1InputStream(new ByteArrayInputStream(eContent.getOctets())); Object firstObject = inputStream.readObject(); if (!(firstObject instanceof ASN1Sequence)) { throw new IllegalStateException( "Expected ASN1Sequence, found " + firstObject.getClass().getSimpleName()); } LDSSecurityObject sod = LDSSecurityObject.getInstance(firstObject); Object nextObject = inputStream.readObject(); if (nextObject != null) { LOGGER.warning("Ignoring extra object found after LDSSecurityObject..."); } return sod; } catch (IOException ioe) { throw new IllegalStateException("Could not read security object in signedData"); } }
From source file:org.poreid.verify.sod.SOD.java
License:Open Source License
protected SOD(byte[] sod, KeyStore keystore) throws SODException { try {// w w w .j a v a2 s .c om cms = new CMSSignedData(sod); lds = LDSSecurityObject.getInstance(cms.getSignedContent().getContent()); this.keystore = keystore; } catch (CMSException ex) { throw new SODException("no foi possivel instanciar o SOD", ex); } }