}
public static Properties loadKeystoreProperties(Message message, String propKey) {
Object o = message.getContextualProperty(propKey);
if (o == null) {
throw new CryptoProviderException("Keystore properties path is not defined");
}
Properties properties = null;
if (o instanceof Properties) {
properties = (Properties)o;
} else if (o instanceof String) {
ResourceManager rm = message.getExchange().get(Bus.class)
.getExtension(ResourceManager.class);
URL url = rm.resolveResource((String)o, URL.class);
try {
if (url == null) {
url = ClassLoaderUtils.getResource((String)o, CryptoProviderUtils.class);
}
if (url == null) {
try {
url = new URL((String)o);
} catch (Exception ex) {
// ignore
}
}
if (url != null) {
InputStream ins = url.openStream();
properties = new Properties();
properties.load(ins);
ins.close();
} else {
throw new CryptoProviderException("Keystore properties url is not resolved: "
+ o);
}
} catch (IOException e) {
throw new CryptoProviderException("Cannot load keystore properties: "
+ e.getMessage(), e);
}
} else if (o instanceof URL) {
properties = new Properties();
try {
InputStream ins = ((URL)o).openStream();
properties.load(ins);
ins.close();
} catch (IOException e) {
throw new CryptoProviderException("Cannot load keystore properties: "
+ e.getMessage(), e);
}
}
if (properties == null) {
throw new CryptoProviderException("Cannot load keystore properties: " + o);
}
return properties;
}