* This method is just to resolve the Email sender and NIO SSL transport passwords.
* @param transport Implementations of ParameterInclude
*/
private void resolveTransportPasswords(ParameterInclude transport) {
SecretResolver secretResolver = axisConfig.getSecretResolver();
if(secretResolver.isInitialized()){
String keyStorePassToken = null;
String keyStoreKeyPassToken = null;
String trustStorePassToken = null;
String emailSenderPassword = null;
if (transport instanceof TransportOutDescription){
keyStorePassToken = "Axis2.Https.Sender.KeyStore.Password";
keyStoreKeyPassToken = "Axis2.Https.Sender.KeyStore.KeyPassword";
trustStorePassToken = "Axis2.Https.Sender.TrustStore.Password";
emailSenderPassword = "Axis2.Mailto.Parameter.Password";
}
if (transport instanceof TransportInDescription){
keyStorePassToken = "Axis2.Https.Listener.KeyStore.Password";
keyStoreKeyPassToken = "Axis2.Https.Listener.KeyStore.KeyPassword";
trustStorePassToken = "Axis2.Https.Listener.TrustStore.Password";
}
Parameter keyParam = transport.getParameter("keystore");
Parameter trustParam = transport.getParameter("truststore");
Parameter emailPasswordParam = transport.getParameter("mail.smtp.password");
if (keyParam != null) {
OMElement ksEle = keyParam.getParameterElement().getFirstElement();
if(ksEle != null){
OMElement storePasswordElement = ksEle.getFirstChildWithName(new QName("Password"));
OMElement keyPasswordElement = ksEle.getFirstChildWithName(new QName("KeyPassword"));
if(secretResolver.isTokenProtected(keyStorePassToken) && storePasswordElement != null){
String storePassword = secretResolver.resolve(keyStorePassToken);
ksEle.getFirstChildWithName(new QName("Password")).setText(storePassword );
}
if(secretResolver.isTokenProtected(keyStoreKeyPassToken) && keyPasswordElement != null){
String keyPassword = secretResolver.resolve(keyStoreKeyPassToken);
ksEle.getFirstChildWithName(new QName("KeyPassword")).setText(keyPassword);
}
}
}
if (trustParam != null) {
OMElement tsEle = trustParam.getParameterElement().getFirstElement();
if(tsEle != null){
OMElement storePasswordElement = tsEle.getFirstChildWithName(new QName("Password"));
if(secretResolver.isTokenProtected(trustStorePassToken) && storePasswordElement != null){
String storePassword = secretResolver.resolve(trustStorePassToken);
tsEle.getFirstChildWithName(new QName("Password")).setText(storePassword );
}
}
}
if(secretResolver.isTokenProtected(emailSenderPassword) && emailPasswordParam != null) {
String emailPassword = secretResolver.resolve(emailSenderPassword);
emailPasswordParam.setValue(emailPassword);
}
}
}