use of org.wso2.securevault.SecretResolver in project carbon-business-process by wso2.
the class UnifiedEndpointFactory method createEndpoint.
public UnifiedEndpoint createEndpoint(OMElement uEPConfigEle) throws AxisFault {
UnifiedEndpoint unifiedEndpoint = new UnifiedEndpoint();
EndpointReferenceHelper.fromOM(unifiedEndpoint, uEPConfigEle, AddressingConstants.Final.WSA_NAMESPACE);
OMElement metadataElem = uEPConfigEle.getFirstChildWithName(UnifiedEndpointConstants.METADATA_Q);
if (metadataElem != null) {
OMElement idElem = metadataElem.getFirstChildWithName(UnifiedEndpointConstants.METADATA_ID_Q);
if (idElem != null) {
unifiedEndpoint.setUepId(idElem.getText());
} else {
log.error("UEP Configuration violation: " + UnifiedEndpointConstants.METADATA_ID_Q + " not found");
}
/**
* Discovery
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.METADATA_DISCOVERY_Q) != null) {
extractDiscoveryConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.METADATA_DISCOVERY_Q));
}
/**
* Timeout
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TIMEOUT_Q) != null) {
extractTimeoutConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TIMEOUT_Q));
}
/**
* WSDL Definitions
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.METADATA_WSDL11_DEFINITIONS_Q) != null) {
unifiedEndpoint.setWsdl11Definitions(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.METADATA_WSDL11_DEFINITIONS_Q));
}
/**
* MessageOutput
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.MESSAGE_OUTPUT_Q) != null) {
extractMessageOutPutConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.MESSAGE_OUTPUT_Q));
}
/**
* Transport
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q) != null) {
extractTransportConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q));
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_USERNAME_Q) != null) {
unifiedEndpoint.setAuthorizationUserName(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_USERNAME_Q).getText());
}
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_PASSWORD_Q) != null) {
OMElement transport_auth_password = metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_PASSWORD_Q);
String secretAlias = transport_auth_password.getAttributeValue(new QName(UnifiedEndpointConstants.SECURE_VAULT_NS, UnifiedEndpointConstants.SECRET_ALIAS_ATTR_NAME));
if (secretAlias != null && secretAlias.trim().length() > 0) {
secretAlias = secretAlias.trim();
SecretResolver secretResolver = SecretResolverFactory.create(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q), false);
/* Setting the secured password */
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(secretAlias)) {
String adminPassword = secretResolver.resolve(secretAlias);
unifiedEndpoint.setAuthorizationPassword(adminPassword);
} else {
/* If secure vault is not configured properly, Reading plain text password */
unifiedEndpoint.setAuthorizationPassword(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_PASSWORD_Q).getText());
}
} else {
unifiedEndpoint.setAuthorizationPassword(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_Q).getFirstChildWithName(UnifiedEndpointConstants.TRANSPORT_AUTHORIZATION_PASSWORD_Q).getText());
}
}
}
/**
* Monitoring
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.MONITORING_Q) != null) {
extractMetadataMonitoringConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.MONITORING_Q));
}
/**
* QoS
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.QOS_Q) != null) {
extractQoSConfig(unifiedEndpoint, metadataElem.getFirstChildWithName(UnifiedEndpointConstants.QOS_Q));
}
/**
* Session
*/
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.SESSION_Q) != null) {
if (metadataElem.getFirstChildWithName(UnifiedEndpointConstants.SESSION_Q).getAttributeValue(UnifiedEndpointConstants.SESSION_TYPE_Q) != null) {
unifiedEndpoint.setSessionType(metadataElem.getFirstChildWithName(UnifiedEndpointConstants.SESSION_Q).getAttributeValue(UnifiedEndpointConstants.SESSION_TYPE_Q));
}
}
}
return unifiedEndpoint;
}
use of org.wso2.securevault.SecretResolver in project carbon-business-process by wso2.
the class HumanTaskServerConfiguration method getAuthenticationConfig.
private void getAuthenticationConfig(File file, TRegServiceAuth authentication) {
// Since secretResolver only accept Element we have to build Element here.
SecretResolver secretResolver = null;
InputStream in = null;
try {
in = new FileInputStream(file);
StAXOMBuilder builder = new StAXOMBuilder(in);
secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
} catch (Exception e) {
log.warn("Error occurred while retrieving secured TaskEngineProtocolHandler configuration.", e);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
}
// Get Username
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(HumanTaskConstants.B4P_REGISTRATIONS_USERNAME_ALIAS)) {
this.registrationServiceAuthUsername = secretResolver.resolve(HumanTaskConstants.B4P_REGISTRATIONS_USERNAME_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded Registration service admin username from secure vault");
}
} else {
if (authentication.getUsername() != null) {
this.registrationServiceAuthUsername = authentication.getUsername();
}
}
// Get Password
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(HumanTaskConstants.B4P_REGISTRATIONS_PASSWORD_ALIAS)) {
this.registrationServiceAuthPassword = secretResolver.resolve(HumanTaskConstants.B4P_REGISTRATIONS_PASSWORD_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded Registration service admin password from secure vault");
}
} else {
if (authentication.getPassword() != null) {
this.registrationServiceAuthPassword = authentication.getPassword();
}
}
}
use of org.wso2.securevault.SecretResolver in project wso2-axis2-transports by wso2.
the class JMSSender method init.
/**
* Initialize the transport sender by reading pre-defined connection factories for
* outgoing messages.
*
* @param cfgCtx the configuration context
* @param transportOut the transport sender definition from axis2.xml
* @throws AxisFault on error
*/
@Override
public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
super.init(cfgCtx, transportOut);
SecretResolver secretResolver = cfgCtx.getAxisConfiguration().getSecretResolver();
connFacManager = new JMSConnectionFactoryManager(transportOut, secretResolver);
log.info("JMS Transport Sender initialized...");
}
use of org.wso2.securevault.SecretResolver in project carbon-business-process by wso2.
the class CoordinationConfiguration method getAuthenticationConfig.
/**
* Get protocol handler admin username and password from secure vault. If secure vault not set then
* parse authentication configuration and extract protocol handler admin username and password
*
* @param file
* @param authentication
*/
private void getAuthenticationConfig(File file, TTaskAuthenticationConfig authentication) {
// Since secretResolver only accept Element we have to build Element here.
SecretResolver secretResolver = null;
InputStream in = null;
try {
in = new FileInputStream(file);
StAXOMBuilder builder = new StAXOMBuilder(in);
secretResolver = SecretResolverFactory.create(builder.getDocumentElement(), true);
} catch (Exception e) {
log.warn("Error occurred while retrieving secured TaskEngineProtocolHandler configuration.", e);
} finally {
try {
in.close();
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
}
// Get Username
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(PROTOCOL_HANDLER_USERNAME_ALIAS)) {
protocolHandlerAdminUser = secretResolver.resolve(PROTOCOL_HANDLER_USERNAME_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded TaskEngine's protocol handler username from secure vault");
}
} else {
if (authentication.getUsername() != null) {
this.protocolHandlerAdminUser = authentication.getUsername();
}
}
// Get Password
if (secretResolver != null && secretResolver.isInitialized() && secretResolver.isTokenProtected(PROTOCOL_HANDLER_PASSWORD_ALIAS)) {
protocolHandlerAdminPassword = secretResolver.resolve(PROTOCOL_HANDLER_PASSWORD_ALIAS);
if (log.isDebugEnabled()) {
log.debug("Loaded TaskEngine's protocol handler password from secure vault");
}
} else {
if (authentication.getPassword() != null) {
this.protocolHandlerAdminPassword = authentication.getPassword();
}
}
}
Aggregations