use of org.wso2.carbon.apimgt.api.model.Provider in project wso2-synapse by wso2.
the class DataSourceInformationFactory method createDataSourceInformation.
/**
* Factory method to create a DataSourceInformation instance based on given properties
*
* @param dsName DataSource Name
* @param properties Properties to create and configure DataSource
* @return DataSourceInformation instance
*/
public static DataSourceInformation createDataSourceInformation(String dsName, Properties properties) {
if (dsName == null || "".equals(dsName)) {
if (log.isDebugEnabled()) {
log.debug("DataSource name is either empty or null, ignoring..");
}
return null;
}
StringBuffer buffer = new StringBuffer();
buffer.append(DataSourceConstants.PROP_SYNAPSE_PREFIX_DS);
buffer.append(DataSourceConstants.DOT_STRING);
buffer.append(dsName);
buffer.append(DataSourceConstants.DOT_STRING);
// Prefix for getting particular data source's properties
String prefix = buffer.toString();
String driver = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DRIVER_CLS_NAME, null);
if (driver == null) {
handleException(prefix + DataSourceConstants.PROP_DRIVER_CLS_NAME + " cannot be found.");
}
String url = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_URL, null);
if (url == null) {
handleException(prefix + DataSourceConstants.PROP_URL + " cannot be found.");
}
DataSourceInformation datasourceInformation = new DataSourceInformation();
datasourceInformation.setAlias(dsName);
datasourceInformation.setDriver(driver);
datasourceInformation.setUrl(url);
String dataSourceName = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DS_NAME, dsName, String.class);
datasourceInformation.setDatasourceName(dataSourceName);
String dsType = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TYPE, DataSourceConstants.PROP_BASIC_DATA_SOURCE, String.class);
datasourceInformation.setType(dsType);
String repositoryType = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_REGISTRY, DataSourceConstants.PROP_REGISTRY_MEMORY, String.class);
datasourceInformation.setRepositoryType(repositoryType);
Integer maxActive = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_ACTIVE, GenericObjectPool.DEFAULT_MAX_ACTIVE, Integer.class);
datasourceInformation.setMaxActive(maxActive);
Integer maxIdle = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_IDLE, GenericObjectPool.DEFAULT_MAX_IDLE, Integer.class);
datasourceInformation.setMaxIdle(maxIdle);
Long maxWait = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_WAIT, GenericObjectPool.DEFAULT_MAX_WAIT, Long.class);
datasourceInformation.setMaxWait(maxWait);
// Construct DriverAdapterCPDS reference
String suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING + DataSourceConstants.PROP_CLASS_NAME;
String className = MiscellaneousUtil.getProperty(properties, prefix + suffix, DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
datasourceInformation.addParameter(suffix, className);
suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING + DataSourceConstants.PROP_FACTORY;
String factory = MiscellaneousUtil.getProperty(properties, prefix + suffix, DataSourceConstants.PROP_CPDS_ADAPTER_DRIVER);
datasourceInformation.addParameter(suffix, factory);
suffix = DataSourceConstants.PROP_CPDS_ADAPTER + DataSourceConstants.DOT_STRING + DataSourceConstants.PROP_NAME;
String name = MiscellaneousUtil.getProperty(properties, prefix + suffix, "cpds");
datasourceInformation.addParameter(suffix, name);
boolean defaultAutoCommit = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DEFAULT_AUTO_COMMIT, true, Boolean.class);
boolean defaultReadOnly = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DEFAULT_READ_ONLY, false, Boolean.class);
boolean testOnBorrow = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TEST_ON_BORROW, true, Boolean.class);
boolean testOnReturn = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TEST_ON_RETURN, false, Boolean.class);
long timeBetweenEvictionRunsMillis = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS, Long.class);
int numTestsPerEvictionRun = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_NUM_TESTS_PER_EVICTION_RUN, GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN, Integer.class);
long minEvictableIdleTimeMillis = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS, Long.class);
boolean testWhileIdle = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_TEST_WHILE_IDLE, false, Boolean.class);
String validationQuery = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_VALIDATION_QUERY, null);
int minIdle = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MIN_IDLE, GenericObjectPool.DEFAULT_MIN_IDLE, Integer.class);
int initialSize = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_INITIAL_SIZE, 0, Integer.class);
int defaultTransactionIsolation = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DEFAULT_TRANSACTION_ISOLATION, -1, Integer.class);
String defaultCatalog = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_DEFAULT_CATALOG, null);
boolean accessToUnderlyingConnectionAllowed = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_ACCESS_TO_UNDERLYING_CONNECTION_ALLOWED, false, Boolean.class);
boolean removeAbandoned = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_REMOVE_ABANDONED, false, Boolean.class);
int removeAbandonedTimeout = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_REMOVE_ABANDONED_TIMEOUT, 300, Integer.class);
boolean logAbandoned = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_LOG_ABANDONED, false, Boolean.class);
boolean poolPreparedStatements = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_POOL_PREPARED_STATEMENTS, false, Boolean.class);
int maxOpenPreparedStatements = MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_MAX_OPEN_PREPARED_STATEMENTS, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL, Integer.class);
datasourceInformation.setDefaultAutoCommit(defaultAutoCommit);
datasourceInformation.setDefaultReadOnly(defaultReadOnly);
datasourceInformation.setTestOnBorrow(testOnBorrow);
datasourceInformation.setTestOnReturn(testOnReturn);
datasourceInformation.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasourceInformation.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
datasourceInformation.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasourceInformation.setTestWhileIdle(testWhileIdle);
datasourceInformation.setMinIdle(minIdle);
datasourceInformation.setDefaultTransactionIsolation(defaultTransactionIsolation);
datasourceInformation.setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
datasourceInformation.setRemoveAbandoned(removeAbandoned);
datasourceInformation.setRemoveAbandonedTimeout(removeAbandonedTimeout);
datasourceInformation.setLogAbandoned(logAbandoned);
datasourceInformation.setPoolPreparedStatements(poolPreparedStatements);
datasourceInformation.setMaxOpenPreparedStatements(maxOpenPreparedStatements);
datasourceInformation.setInitialSize(initialSize);
if (validationQuery != null && !"".equals(validationQuery)) {
datasourceInformation.setValidationQuery(validationQuery);
}
if (defaultCatalog != null && !"".equals(defaultCatalog)) {
datasourceInformation.setDefaultCatalog(defaultCatalog);
}
datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_IC_FACTORY, MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_IC_FACTORY, null));
// Provider URL
datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_PROVIDER_URL, MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_PROVIDER_URL, null));
datasourceInformation.addProperty(prefix + DataSourceConstants.PROP_PROVIDER_PORT, MiscellaneousUtil.getProperty(properties, prefix + DataSourceConstants.PROP_PROVIDER_PORT, null));
String passwordPrompt = MiscellaneousUtil.getProperty(properties, prefix + SecurityConstants.PROP_PASSWORD_PROMPT, "Password for datasource " + dsName, String.class);
SecretInformation secretInformation = SecretInformationFactory.createSecretInformation(properties, prefix, passwordPrompt);
secretInformation.setToken(dsName + "." + SecurityConstants.PROP_PASSWORD);
datasourceInformation.setSecretInformation(secretInformation);
return datasourceInformation;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project wso2-synapse by wso2.
the class CryptoUtil method init.
/**
* Method to initialise crypto util. which will generate the required chiper etc.
*
* @param secureVaultProperties
* @throws org.apache.axis2.AxisFault
*/
public void init(Properties secureVaultProperties) throws AxisFault {
// Create a KeyStore Information for private key entry KeyStore
IdentityKeyStoreInformation identityInformation = KeyStoreInformationFactory.createIdentityKeyStoreInformation(secureVaultProperties);
String identityKeyPass = null;
String identityStorePass = null;
if (identityInformation != null) {
identityKeyPass = identityInformation.getKeyPasswordProvider().getResolvedSecret();
identityStorePass = identityInformation.getKeyStorePasswordProvider().getResolvedSecret();
}
if (!Util.validatePasswords(identityStorePass, identityKeyPass)) {
if (log.isDebugEnabled()) {
log.info("Either Identity or Trust keystore password is mandatory" + " in order to initialized secret manager.");
}
throw new AxisFault("Error inititialising cryptoutil, required parameters not provided");
}
IdentityKeyStoreWrapper identityKeyStoreWrapper = new IdentityKeyStoreWrapper();
identityKeyStoreWrapper.init(identityInformation, identityKeyPass);
algorithm = MiscellaneousUtil.getProperty(secureVaultProperties, CryptoConstants.CIPHER_ALGORITHM, CryptoConstants.CIPHER_ALGORITHM_DEFAULT);
String provider = MiscellaneousUtil.getProperty(secureVaultProperties, CryptoConstants.SECURITY_PROVIDER, null);
String cipherType = MiscellaneousUtil.getProperty(secureVaultProperties, CryptoConstants.CIPHER_TYPE, null);
String inTypeString = MiscellaneousUtil.getProperty(secureVaultProperties, CryptoConstants.INPUT_ENCODE_TYPE, null);
inType = Util.getEncodeDecodeType(inTypeString, EncodeDecodeTypes.BASE64);
String outTypeString = MiscellaneousUtil.getProperty(secureVaultProperties, CryptoConstants.OUTPUT_ENCODE_TYPE, null);
outType = Util.getEncodeDecodeType(outTypeString, null);
CipherInformation cipherInformation = new CipherInformation();
cipherInformation.setAlgorithm(algorithm);
cipherInformation.setCipherOperationMode(CipherOperationMode.DECRYPT);
cipherInformation.setType(cipherType);
// skipping decoding encoding in securevault
cipherInformation.setInType(null);
// skipping decoding encoding in securevault
cipherInformation.setOutType(null);
if (provider != null && !provider.isEmpty()) {
if (CryptoConstants.BOUNCY_CASTLE_PROVIDER.equals(provider)) {
Security.addProvider(new BouncyCastleProvider());
cipherInformation.setProvider(provider);
}
// todo need to add other providers if there are any.
}
baseCipher = CipherFactory.createCipher(cipherInformation, identityKeyStoreWrapper);
isInitialized = true;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project core-util by WSO2Telco.
the class UUIDPCRService method updateServiceProviderMap.
private void updateServiceProviderMap(String appId) throws PCRException {
if (DEBUG)
log.debug("Updating Service Provider Map");
try {
OAuthConsumerAppDTO apps = authApplicationData.getApplicationData(appId);
if (DEBUG)
log.debug("Application List recieved");
if (apps == null) {
log.error("Application data not found - updateServiceProviderMap");
throw new PCRException("Null Application list - updateServiceProviderMap");
}
String callbackUrl = apps.getCallbackUrl();
String sector = SectorUtil.getSectorIdFromUrl(callbackUrl);
KeyValueBasedPcrDAOImpl keyValueBasedPcrDAOImpl = new KeyValueBasedPcrDAOImpl();
keyValueBasedPcrDAOImpl.createNewSPEntry(sector, appId, true);
} catch (Exception e) {
log.error("error in retrieving application data - updateServiceProviderMap", e);
throw new PCRException("error in retrieving application data - updateServiceProviderMap");
}
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method fillPartnerLinks.
// private java.lang.String[] getServiceLocationForProcess(QName processId)
// throws ProcessManagementException {
// AxisConfiguration axisConf = getConfigContext().getAxisConfiguration();
// Map<String, AxisService> services = axisConf.getServices();
// ArrayList<String> serviceEPRs = new ArrayList<String>();
//
// for (AxisService service : services.values()) {
// Parameter pIdParam = service.getParameter(BPELConstants.PROCESS_ID);
// if (pIdParam != null) {
// if (pIdParam.getValue().equals(processId)) {
// serviceEPRs.addAll(Arrays.asList(service.getEPRs()));
// }
// }
// }
//
// if (serviceEPRs.size() > 0) {
// return serviceEPRs.toArray(new String[serviceEPRs.size()]);
// }
//
// String errMsg = "Cannot find service for process: " + processId;
// log.error(errMsg);
// throw new ProcessManagementException(errMsg);
// }
private void fillPartnerLinks(ProcessInfoType pInfo, TDeployment.Process processInfo) throws ProcessManagementException {
if (processInfo.getProvideList() != null) {
EndpointReferencesType eprsType = new EndpointReferencesType();
for (TProvide provide : processInfo.getProvideList()) {
String plinkName = provide.getPartnerLink();
TService service = provide.getService();
/* NOTE:Service cannot be null for provider partner link*/
if (service == null) {
String errorMsg = "Error in <provide> element for process " + processInfo.getName() + " partnerlink" + plinkName + " did not identify an endpoint";
log.error(errorMsg);
throw new ProcessManagementException(errorMsg);
}
if (log.isDebugEnabled()) {
log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
}
QName serviceName = service.getName();
EndpointRef_type0 eprType = new EndpointRef_type0();
eprType.setPartnerLink(plinkName);
eprType.setService(serviceName);
ServiceLocation sLocation = new ServiceLocation();
try {
String url = Utils.getTryitURL(serviceName.getLocalPart(), getConfigContext());
sLocation.addServiceLocation(url);
String[] wsdls = Utils.getWsdlInformation(serviceName.getLocalPart(), getConfigContext().getAxisConfiguration());
if (wsdls.length == 2) {
if (wsdls[0].endsWith("?wsdl")) {
sLocation.addServiceLocation(wsdls[0]);
} else {
sLocation.addServiceLocation(wsdls[1]);
}
}
} catch (AxisFault axisFault) {
String errMsg = "Error while getting try-it url for the service: " + serviceName;
log.error(errMsg, axisFault);
throw new ProcessManagementException(errMsg, axisFault);
}
eprType.setServiceLocations(sLocation);
eprsType.addEndpointRef(eprType);
}
pInfo.setEndpoints(eprsType);
}
// if (processInfo.getInvokeList() != null) {
// for (TInvoke invoke : processInfo.getInvokeList()) {
// String plinkName = invoke.getPartnerLink();
// TService service = invoke.getService();
// /* NOTE:Service can be null for partner links*/
// if (service == null) {
// continue;
// }
// if (log.isDebugEnabled()) {
// log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" +
// plinkName + " -->" + service);
// }
//
// QName serviceName = service.getName();
// }
// }
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-business-process by wso2.
the class JPATaskUtil method assignHumanRoles.
private static void assignHumanRoles(TaskDAO task, PeopleQueryEvaluator peopleQueryEvaluator, TGenericHumanRoleAssignment roleAssignment, GenericHumanRole.GenericHumanRoleType type, EvaluationContext evaluationContext) throws HumanTaskException {
OrganizationalEntityProvider provider = OrganizationalEntityProviderFactory.getOrganizationalEntityProvider(roleAssignment.getFrom());
List<OrganizationalEntityDAO> orgEntities = provider.getOrganizationalEntities(peopleQueryEvaluator, roleAssignment.getFrom(), evaluationContext);
GenericHumanRole humanRole = new GenericHumanRole();
humanRole.setType(type);
humanRole.setOrgEntities(orgEntities);
humanRole.setTask(task);
for (OrganizationalEntityDAO oe : orgEntities) {
oe.addGenericHumanRole(humanRole);
}
task.addHumanRole(humanRole);
}
Aggregations