}
@Override
public void write(final OutputStream outputStream, final String password) throws IOException {
try {
XmlDocument document = new XmlDocument(XMLStore.STORE_ELEMENT);
XmlElement root = document.getRoot();
root.setAttribute(XMLStore.ENCODING_ATTRIBUTE, XMLStore.ENCODING);
XmlElement certificates = root.addElement(XMLStore.CERTIFICATES_ELEMENT);
XmlElement privateKeys = root.addElement(XMLStore.PRIVATE_KEYS_ELEMENT);
XmlElement publicKeys = root.addElement(XMLStore.PUBLIC_KEYS_ELEMENT);
XmlElement secretKeys = root.addElement(XMLStore.SECRET_KEYS_ELEMENT);
for (Entry<String, Certificate> entry : this.getCertificateMap().entrySet()) {
String alias = entry.getKey();
Certificate certificate = entry.getValue();
this.addCertificateElement(certificates, alias, certificate);
}
for (Entry<String, PrivateKeyHolder> entry : this.getPrivateKeyMap().entrySet()) {
String alias = entry.getKey();
PrivateKeyHolder holder = entry.getValue();
this.addPrivateKeyElement(privateKeys, alias, holder);
}
for (Entry<String, PublicKey> entry : this.getPublicKeyMap().entrySet()) {
String alias = entry.getKey();
PublicKey publicKey = entry.getValue();
this.addPublicKeyElement(publicKeys, alias, publicKey);
}
for (Entry<String, SecretKey> entry : this.getSecretKeyMap().entrySet()) {
String alias = entry.getKey();
SecretKey secretKey = entry.getValue();
this.addSecretKeyElement(secretKeys, alias, secretKey);
}
document.write(outputStream);
} catch (GeneralSecurityException e) {
throw new StoreException(e);
}
}