/** * Decrypt a key from a passed in EncryptedKey structure. This version * is used mainly internally, when the cipher already has an * EncryptedData loaded. The algorithm URI will be read from the * EncryptedData * * @param encryptedKey Previously loaded EncryptedKey that needs * to be decrypted. * @return a key corresponding to the given type * @throws XMLEncryptionException */ public Key decryptKey(EncryptedKey encryptedKey) throws XMLEncryptionException { return decryptKey(encryptedKey, ed.getEncryptionMethod().getAlgorithm()); }
/** * Constructor for processing encrypted octets * * @param input The <code>EncryptedType</code> object to read * the bytes from. * @throws XMLEncryptionException {@link XMLEncryptionException} */ public XMLCipherInput(EncryptedType input) throws XMLEncryptionException { cipherData = input == null ? null : input.getCipherData(); mode = XMLCipher.DECRYPT_MODE; if (cipherData == null) { throw new XMLEncryptionException("CipherData is null"); } }
/** * Create an EncryptionMethod object * * @param algorithm Algorithm for the encryption * @return a new <code>EncryptionMethod</code> */ public EncryptionMethod createEncryptionMethod(String algorithm) { return factory.newEncryptionMethod(algorithm); }
private Key getDecipheredOtherPartyEntropy(Object encryptedKey, Key privKey) throws XMLEncryptionException { if ( encryptedKey instanceof EncryptedKey ) { EncryptedKey encKey = (EncryptedKey)encryptedKey; XMLCipher cipher = XMLCipher.getInstance(); cipher.setKEK(privKey); cipher.decryptKey(encKey); return null; } else { return null; } }
/** * Encrypts a key to an EncryptedKey structure * * @param doc the Context document that will be used to general DOM * @param key Key to encrypt (will use previously set KEK to * perform encryption * @return the <code>EncryptedKey</code> * @throws XMLEncryptionException */ public EncryptedKey encryptKey(Document doc, Key key) throws XMLEncryptionException { return encryptKey(doc, key, null, null); }
/** * * @return the XML Element form of that Transforms */ public Element toElement() { if (getDocument() == null) { setDocument(contextDocument); } return getElement(); }
/** * Create a new EncryptionProperty element * @return a new <code>EncryptionProperty</code> */ public EncryptionProperty createEncryptionProperty() { return factory.newEncryptionProperty(); }
/** * Create a new Transforms object * <p> * <b>Note</b>: A context document <i>must</i> have been set * elsewhere (possibly via a call to doFinal). If not, use the * createTransforms(Document) method. * @return a new <code>Transforms</code> */ public Transforms createTransforms() { return factory.newTransforms(); }
/** * Create a CipherData object * * @param type Type of this CipherData (either VALUE_TUPE or * REFERENCE_TYPE) * @return a new <code>CipherData</code> */ public CipherData createCipherData(int type) { return factory.newCipherData(type); }
/** * Create a CipherReference object * * @param uri The URI that the reference will refer * @return a new <code>CipherReference</code> */ public CipherReference createCipherReference(String uri) { return factory.newCipherReference(uri); }
/** * Dereferences the input and returns it as a single byte array. * * @throws XMLEncryptionException * @return The decripted bytes. */ public byte[] getBytes() throws XMLEncryptionException { if (mode == XMLCipher.DECRYPT_MODE) { return getDecryptBytes(); } return null; }
/** * Create an AgreementMethod object * * @param algorithm Algorithm of the agreement method * @return a new <code>AgreementMethod</code> */ public AgreementMethod createAgreementMethod(String algorithm) { return factory.newAgreementMethod(algorithm); }
/** * @param uri * @return a new CipherReference */ CipherReference newCipherReference(String uri) { return new CipherReferenceImpl(uri); }
/** * @param algorithm * @return a new AgreementMethod */ AgreementMethod newAgreementMethod(String algorithm) { return new AgreementMethodImpl(algorithm); }
/** * @param type * @return a new CipherData * */ CipherData newCipherData(int type) { return new CipherDataImpl(type); }
/** * @param value * @return a new CipherValue */ CipherValue newCipherValue(String value) { return new CipherValueImpl(value); }
/** * @param encryptedData * @return the XML Element form of that EncryptedData */ Element toElement(EncryptedData encryptedData) { return ((EncryptedDataImpl) encryptedData).toElement(); }
/** * @param referenceList * @return the XML Element form of that ReferenceList */ Element toElement(ReferenceList referenceList) { return ((ReferenceListImpl) referenceList).toElement(); }
/** * @return a new EncryptionProperty */ EncryptionProperty newEncryptionProperty() { return new EncryptionPropertyImpl(); }
/** * Returns a <code>byte[]</code> representation of the specified * <code>Element</code>. * * @param element the <code>Element</code> to serialize. * @return the <code>byte[]</code> representation of the serilaized * <code>Element</code>. * @throws Exception */ public byte[] serializeToByteArray(Element element) throws Exception { return canonSerializeToByteArray(element); }