/** * Add this public key to the KeyInfo. This will include the complete key in * the KeyInfo structure. * * @param pk */ public void addKeyInfo(PublicKey pk) { this.getKeyInfo().add(pk); }
private void addX509Certificate(X509Certificate cert, KeyInfo keyInfo) { X509Data data = new X509Data(doc); try { data.addCertificate(cert); } catch (XMLSecurityException se) { throw new RuntimeException( "Adding the X509Certificate to X509Data object failed", se); } keyInfo.add(data); }
/** * Method addKeyValue * * @param unknownKeyValueElement */ public void addKeyValue(Element unknownKeyValueElement) { this.add(new KeyValue(getDocument(), unknownKeyValueElement)); }
/** * Method add * * @param rsakeyvalue */ public void add(RSAKeyValue rsakeyvalue) { this.add(new KeyValue(getDocument(), rsakeyvalue)); }
/** * Method add * * @param pk */ public void add(PublicKey pk) { this.add(new KeyValue(getDocument(), pk)); }
/** * Method addKeyName * * @param keynameString */ public void addKeyName(String keynameString) { this.add(new KeyName(getDocument(), keynameString)); }
/** * Method add * * @param dsakeyvalue */ public void add(DSAKeyValue dsakeyvalue) { this.add(new KeyValue(getDocument(), dsakeyvalue)); }
/** * Method addDEREncodedKeyValue * * @param pk * @throws XMLSecurityException */ public void addDEREncodedKeyValue(PublicKey pk) throws XMLSecurityException { this.add(new DEREncodedKeyValue(getDocument(), pk)); }
/** * Method addKeyValue * * @param pk */ public void addKeyValue(PublicKey pk) { this.add(new KeyValue(getDocument(), pk)); }
/** * Method addMgmtData * * @param mgmtdata */ public void addMgmtData(String mgmtdata) { this.add(new MgmtData(getDocument(), mgmtdata)); }
/** * Method addRetrievalMethod * * @param uri * @param transforms * @param Type */ public void addRetrievalMethod(String uri, Transforms transforms, String Type) { this.add(new RetrievalMethod(getDocument(), uri, transforms, Type)); }
/** * Method addKeyInfoReference * * @param URI * @throws XMLSecurityException */ public void addKeyInfoReference(String URI) throws XMLSecurityException { this.add(new KeyInfoReference(getDocument(), URI)); }
private void addKeyInfo(List respondWiths, String aliase, X509Certificate[] certs, KeyBindingAbstractType abstractType) { KeyInfo keyInfo = new KeyInfo(doc); for (Iterator iterator = respondWiths.iterator(); iterator.hasNext();) { RespondWith respondWith = (RespondWith) iterator.next(); if (respondWith.equals(RespondWith.KEY_NAME)) { KeyName keyName = new KeyName(doc, aliase); keyInfo.add(keyName); } else if (respondWith.equals(RespondWith.KEY_VALUE)) { PublicKey publicKey = certs[0].getPublicKey(); KeyValue keyValue = new KeyValue(doc, publicKey); keyInfo.add(keyValue); } else if (respondWith.equals(RespondWith.X_509_CERT)) { addX509Certificate(certs[0], keyInfo); } else if (respondWith.equals(RespondWith.X_509_CHAIN)) { for (int i = 0; i < certs.length; i++) { addX509Certificate(certs[i], keyInfo); } } else { // TODO Implement the other RespondWith elements. } } abstractType.setKeyInfo(keyInfo); }
/** * Add an X509 Certificate to the KeyInfo. This will include the whole cert * inside X509Data/X509Certificate tags. * * @param cert Certificate to be included. This should be the certificate of * the key that was used to sign. * @throws XMLSecurityException */ public void addKeyInfo(X509Certificate cert) throws XMLSecurityException { X509Data x509data = new X509Data(getDocument()); x509data.addCertificate(cert); this.getKeyInfo().add(x509data); }
X509Data xData = new X509Data(document); xData.addIssuerSerial(cer.getIssuerDN().getName(), cer.getSerialNumber()); kiEnc.add(xData); key.setKeyInfo(kiEnc);
X509Data xData = new X509Data(document); xData.addIssuerSerial(cer.getIssuerDN().getName(), cer.getSerialNumber()); kiEnc.add(xData); key.setKeyInfo(kiEnc);
X509Data xData = new X509Data(document); xData.addIssuerSerial(cer.getIssuerDN().getName(), cer.getSerialNumber()); kiEnc.add(xData); key.setKeyInfo(kiEnc);
public Document encrypt(Document doc, EncryptionOptions options) throws SecurityException { try { org.w3c.dom.Document dom = fomToDom(doc, options); Key dek = options.getDataEncryptionKey(); Key kek = options.getKeyEncryptionKey(); String dalg = options.getDataCipherAlgorithm(); String kalg = options.getKeyCipherAlgorithm(); boolean includeki = options.includeKeyInfo(); EncryptedKey enckey = null; XMLCipher xmlCipher = XMLCipher.getInstance(dalg); xmlCipher.init(XMLCipher.ENCRYPT_MODE, dek); if (includeki && kek != null && dek != null) { XMLCipher keyCipher = XMLCipher.getInstance(kalg); keyCipher.init(XMLCipher.WRAP_MODE, kek); enckey = keyCipher.encryptKey(dom, dek); EncryptedData encdata = xmlCipher.getEncryptedData(); KeyInfo keyInfo = new KeyInfo(dom); keyInfo.add(enckey); encdata.setKeyInfo(keyInfo); } dom = xmlCipher.doFinal(dom, dom.getDocumentElement(), false); return domToFom(dom, options); } catch (Exception e) { throw new SecurityException(e); } }