@SuppressWarnings("unchecked") @Override public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { LOG.log(POILogger.DEBUG, "select key"); if (null == keyInfo) { throw new KeySelectorException("no ds:KeyInfo present"); } List<XMLStructure> keyInfoContent = keyInfo.getContent(); certChain.clear(); for (XMLStructure keyInfoStructure : keyInfoContent) { if (!(keyInfoStructure instanceof X509Data)) { continue; } X509Data x509Data = (X509Data) keyInfoStructure; List<?> x509DataList = x509Data.getContent(); for (Object x509DataObject : x509DataList) { if (!(x509DataObject instanceof X509Certificate)) { continue; } X509Certificate certificate = (X509Certificate) x509DataObject; LOG.log(POILogger.DEBUG, "certificate", certificate.getSubjectX500Principal()); certChain.add(certificate); } } if (certChain.isEmpty()) { throw new KeySelectorException("No key found!"); } return this; }
public X509DataKeySelectorResult(X509Data data) { List content = data.getContent(); unrecognizedObjects = new ArrayList<XMLStructure>(content.size()); for (Object obj : content) { if (obj instanceof X509IssuerSerial) x509IssuerSerial = (X509IssuerSerial) obj; else if (obj instanceof X509Certificate) x509Certificate = (X509Certificate) obj; else if (obj instanceof X509CRL) x509CRL = (X509CRL) obj; else if (obj instanceof String) subjectName = (String) obj; else if (obj instanceof byte[]) subjectKeyId = (byte[]) obj; else unrecognizedObjects.add((XMLStructure) obj); } }
public X509Certificate getX509Certificate() throws MarshalException { X509Data x509Data = getX509Data(); if (x509Data != null) { for (Object o1 : x509Data.getContent()) { if (o1 instanceof X509Certificate) { return (X509Certificate) o1; } } } return null; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof X509Data)) { return false; } X509Data oxd = (X509Data)o; List<?> ocontent = oxd.getContent(); int size = content.size(); if (size != ocontent.size()) { return false; } for (int i = 0; i < size; i++) { Object x = content.get(i); Object ox = ocontent.get(i); if (x instanceof byte[]) { if (!(ox instanceof byte[]) || !Arrays.equals((byte[])x, (byte[])ox)) { return false; } } else { if (!(x.equals(ox))) { return false; } } } return true; }
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { Iterator ki = keyInfo.getContent().iterator(); while (ki.hasNext()) { XMLStructure info = (XMLStructure) ki.next(); if (!(info instanceof X509Data)) continue; X509Data x509Data = (X509Data) info; Iterator xi = x509Data.getContent().iterator(); while (xi.hasNext()) { Object o = xi.next(); if (!(o instanceof X509Certificate)) continue; this.certificate = (X509Certificate) o; final PublicKey key = certificate.getPublicKey(); // Make sure the algorithm is compatible with the method. if (algEquals(method.getAlgorithm(), key.getAlgorithm())) return new KeySelectorResult() { public Key getKey() { return key; } }; } } throw new KeySelectorException("No key found!"); }
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { Iterator ki = keyInfo.getContent().iterator(); while (ki.hasNext()) { XMLStructure info = (XMLStructure) ki.next(); if (!(info instanceof X509Data)) continue; X509Data x509Data = (X509Data) info; Iterator xi = x509Data.getContent().iterator(); while (xi.hasNext()) { Object o = xi.next(); if (!(o instanceof X509Certificate)) continue; final PublicKey key = ((X509Certificate)o).getPublicKey(); // Make sure the algorithm is compatible // with the method. if (algEquals(method.getAlgorithm(), key.getAlgorithm())) { return new KeySelectorResult() { public Key getKey() { return key; } }; } } } throw new KeySelectorException("No key found!"); }
public KeySelectorResult select(KeyInfo keyInfo, KeySelector.Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { @SuppressWarnings("rawtypes") Iterator ki = keyInfo.getContent().iterator(); while (ki.hasNext()) { XMLStructure info = (XMLStructure) ki.next(); if (!(info instanceof X509Data)) continue; X509Data x509Data = (X509Data) info; @SuppressWarnings("rawtypes") Iterator xi = x509Data.getContent().iterator(); while (xi.hasNext()) { Object o = xi.next(); if (!(o instanceof X509Certificate)) continue; final PublicKey key = ((X509Certificate)o).getPublicKey(); // Make sure the algorithm is compatible // with the method. if (algEquals(method.getAlgorithm(), key.getAlgorithm())) { return new KeySelectorResult() { public Key getKey() { return key; } }; } } } throw new KeySelectorException("No key found!"); }
if (kiType instanceof X509Data) { X509Data xd = (X509Data) kiType; Object[] entries = xd.getContent().toArray(); X509CRL crl = null; for (int i = 0; ( i < entries.length); i++) {
List<Object> x509DataList = x509Data.getContent(); for (Object x509DataObject : x509DataList) { if (false == (x509DataObject instanceof X509Certificate)) {
@Override public KeySelectorResult select(final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context) throws KeySelectorException { for (final Object object : keyInfo.getContent()) { final XMLStructure info = (XMLStructure) object; if (info instanceof X509Data) { final X509Data x509Data = (X509Data) info; for (final Object certificado : x509Data.getContent()) { if (certificado instanceof X509Certificate) { final X509Certificate x509Certificate = (X509Certificate) certificado; if (this.algEquals(method.getAlgorithm(), x509Certificate.getPublicKey().getAlgorithm())) { return x509Certificate::getPublicKey; } } } } } throw new KeySelectorException("Nao foi localizada a chave do certificado."); }
for (final Object aX509Element : x509Data.getContent ())
for (final Object aX509Element : x509Data.getContent ())
} else if (list.get(i) instanceof X509Data) { X509Data x509Data = (X509Data)list.get(i); for (int j = 0; j < x509Data.getContent().size(); j++) { if (x509Data.getContent().get(j) instanceof X509Certificate) { ReceivedCredential receivedKey = new ReceivedCredential(); receivedKey.setX509Cert((X509Certificate)x509Data.getContent().get(j)); return receivedKey;
} else if (list.get(i) instanceof X509Data) { X509Data x509Data = (X509Data)list.get(i); for (int j = 0; j < x509Data.getContent().size(); j++) { if (x509Data.getContent().get(j) instanceof X509Certificate) { ReceivedCredential receivedKey = new ReceivedCredential(); receivedKey.setX509Cert((X509Certificate)x509Data.getContent().get(j)); return receivedKey;
@SuppressWarnings("unchecked") @Override public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { LOG.log(POILogger.DEBUG, "select key"); if (null == keyInfo) { throw new KeySelectorException("no ds:KeyInfo present"); } List<XMLStructure> keyInfoContent = keyInfo.getContent(); certChain.clear(); for (XMLStructure keyInfoStructure : keyInfoContent) { if (!(keyInfoStructure instanceof X509Data)) { continue; } X509Data x509Data = (X509Data) keyInfoStructure; List<?> x509DataList = x509Data.getContent(); for (Object x509DataObject : x509DataList) { if (!(x509DataObject instanceof X509Certificate)) { continue; } X509Certificate certificate = (X509Certificate) x509DataObject; LOG.log(POILogger.DEBUG, "certificate", certificate.getSubjectX500Principal()); certChain.add(certificate); } } if (certChain.isEmpty()) { throw new KeySelectorException("No key found!"); } return this; }
for(final Object d : ((X509Data) s).getContent()) { if(d instanceof X509Certificate) { pk = ((Certificate) d).getPublicKey();
for(final Object d : ((X509Data) s).getContent()) { if(d instanceof X509Certificate) { pk = ((Certificate) d).getPublicKey();
public static void marshal(XmlWriter xwriter, X509Data x509Data, String dsPrefix, XMLCryptoContext context) throws MarshalException { xwriter.writeStartElement(dsPrefix, "X509Data", XMLSignature.XMLNS); List<?> content = x509Data.getContent(); // append children and preserve order for (int i = 0, size = content.size(); i < size; i++) { Object object = content.get(i); if (object instanceof X509Certificate) { marshalCert(xwriter, (X509Certificate) object, dsPrefix); } else if (object instanceof XMLStructure) { xwriter.marshalStructure((XMLStructure) object, dsPrefix, context); } else if (object instanceof byte[]) { marshalSKI(xwriter, (byte[]) object, dsPrefix); } else if (object instanceof String) { marshalSubjectName(xwriter, (String) object, dsPrefix); } else if (object instanceof X509CRL) { marshalCRL(xwriter, (X509CRL) object, dsPrefix); } } xwriter.writeEndElement(); // "X509Data" }
@Override public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException { if ( keyInfo == null ) { throw new KeySelectorException ( "Null KeyInfo object!" ); } final SignatureMethod sm = (SignatureMethod)method; final List<?> list = keyInfo.getContent (); for ( final Object l : list ) { final XMLStructure xmlStructure = (XMLStructure)l; if ( xmlStructure instanceof X509Data ) { for ( final Object o : ( (X509Data)xmlStructure ).getContent () ) { KeySelectorResult result = null; if ( o instanceof X509Certificate ) { result = findPublicKey ( (X509Certificate)o, sm ); } if ( result != null ) { return result; } } } } throw new KeySelectorException ( "No KeyValue element found!" ); }
@Override public KeySelectorResult select ( final KeyInfo keyInfo, final KeySelector.Purpose purpose, final AlgorithmMethod method, final XMLCryptoContext context ) throws KeySelectorException { if ( keyInfo == null ) { throw new KeySelectorException ( "Null KeyInfo object!" ); } final SignatureMethod sm = (SignatureMethod)method; final List<?> list = keyInfo.getContent (); for ( final Object l : list ) { final XMLStructure xmlStructure = (XMLStructure)l; if ( xmlStructure instanceof X509Data ) { for ( final Object o : ( (X509Data)xmlStructure ).getContent () ) { KeySelectorResult result = null; if ( o instanceof X509Certificate ) { result = findPublicKey ( (X509Certificate)o, sm ); } if ( result != null ) { return result; } } } } throw new KeySelectorException ( "No KeyValue element found!" ); }