use of org.wso2.securevault.PasswordManager in project wso2-synapse by wso2.
the class JmxAdapter method createContextMap.
/**
* Creates an environment context map containing the configuration used to start the
* server connector.
*
* @return an environment context map containing the configuration used to start the server
* connector
*/
private Map<String, Object> createContextMap() {
Map<String, Object> env = new HashMap<String, Object>();
if (jmxInformation.isAuthenticate()) {
if (jmxInformation.getRemotePasswordFile() != null) {
env.put("jmx.remote.x.password.file", jmxInformation.getRemotePasswordFile());
} else {
SecretInformation secretInformation = jmxInformation.getSecretInformation();
// Get the global secret resolver
// TODO This should be properly implemented if JMX adapter is going to use out side synapse
PasswordManager pwManager = PasswordManager.getInstance();
if (pwManager.isInitialized()) {
secretInformation.setGlobalSecretResolver(pwManager.getSecretResolver());
}
env.put(JMXConnectorServer.AUTHENTICATOR, new JmxSecretAuthenticator(jmxInformation.getSecretInformation()));
}
if (jmxInformation.getRemoteAccessFile() != null) {
env.put("jmx.remote.x.access.file", jmxInformation.getRemoteAccessFile());
}
} else {
log.warn("Using unsecured JMX remote access!");
}
if (jmxInformation.isRemoteSSL()) {
log.info("Activated SSL communication");
env.put("jmx.remote.rmi.client.socket.factory", new SslRMIClientSocketFactory());
env.put("jmx.remote.rmi.server.socket.factory", new SslRMIServerSocketFactory());
}
return env;
}
use of org.wso2.securevault.PasswordManager in project wso2-synapse by wso2.
the class EventSourceFactory method createEventSource.
@SuppressWarnings({ "UnusedDeclaration" })
public static SynapseEventSource createEventSource(OMElement elem, Properties properties) {
SynapseEventSource eventSource = null;
OMAttribute name = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
if (name == null) {
handleException("The 'name' attribute is required for a event source de");
} else {
eventSource = new SynapseEventSource(name.getAttributeValue());
}
OMElement subscriptionManagerElem = elem.getFirstChildWithName(SUBSCRIPTION_MANAGER_QNAME);
if (eventSource != null && subscriptionManagerElem != null) {
OMAttribute clazz = subscriptionManagerElem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
if (clazz != null) {
String className = clazz.getAttributeValue();
try {
Class subscriptionManagerClass = Class.forName(className);
SubscriptionManager manager = (SubscriptionManager) subscriptionManagerClass.newInstance();
Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
while (itr.hasNext()) {
OMElement propElem = (OMElement) itr.next();
String propName = propElem.getAttribute(new QName("name")).getAttributeValue();
String propValue = propElem.getAttribute(new QName("value")).getAttributeValue();
if (propName != null && !"".equals(propName.trim()) && propValue != null && !"".equals(propValue.trim())) {
propName = propName.trim();
propValue = propValue.trim();
PasswordManager passwordManager = PasswordManager.getInstance();
String key = eventSource.getName() + "." + propName;
if (passwordManager.isInitialized() && passwordManager.isTokenProtected(key)) {
eventSource.putConfigurationProperty(propName, propValue);
propValue = passwordManager.resolve(propValue);
}
manager.addProperty(propName, propValue);
}
}
eventSource.setSubscriptionManager(manager);
eventSource.getSubscriptionManager().init();
} catch (ClassNotFoundException e) {
handleException("SubscriptionManager class not found", e);
} catch (IllegalAccessException e) {
handleException("Unable to access the SubscriptionManager object", e);
} catch (InstantiationException e) {
handleException("Unable to instantiate the SubscriptionManager object", e);
}
} else {
handleException("SynapseSubscription manager class is a required attribute");
}
} else {
handleException("SynapseSubscription Manager has not been specified for the event source");
}
try {
createStaticSubscriptions(elem, eventSource);
} catch (EventException e) {
handleException("Static subscription creation failure", e);
}
return eventSource;
}
use of org.wso2.securevault.PasswordManager in project wso2-synapse by wso2.
the class ServerManager method doShutdown.
/**
* Helper method to shutdown the the ServerManager
*/
private void doShutdown() {
ServerState serverState = ServerStateDetectionStrategy.currentState(serverContextInformation, serverConfigurationInformation);
if (serverState == ServerState.INITIALIZED || serverState == ServerState.STOPPED) {
// shutdown debug manager and close TCP connection in the debug interface
if (serverContextInformation.isServerDebugModeEnabled()) {
serverContextInformation.getSynapseDebugManager().shutdownDebugManager();
}
// Shutdown global PasswordManager instance used in synapse
PasswordManager passwordManager = PasswordManager.getInstance();
if (passwordManager.isInitialized()) {
PasswordManager.getInstance().shutDown();
}
// un-register the ServerManager MBean
unRegisterMBean();
// destroy the SynapseController
synapseController.destroy();
// mark as destroyed
changeState(ServerState.UNDETERMINED);
} else {
// if the server cannot be destroyed just set the current state as the server state
changeState(serverState);
}
}
Aggregations