use of org.apache.axis2.context.ConfigurationContext in project airavata by apache.
the class AuthResponse method main.
public static void main(String[] args) throws AuthenticationException, AiravataSecurityException, AxisFault {
String accessToken = authenticate("master@master.airavata", "master").getAccess_token();
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, null);
DefaultOAuthClient defaultOAuthClient = new DefaultOAuthClient(hostName + "/services/", username, password, configContext);
OAuth2TokenValidationResponseDTO tokenValidationRequestDTO = defaultOAuthClient.validateAccessToken(accessToken);
String authorizedUser = tokenValidationRequestDTO.getAuthorizedUser();
AuthzToken authzToken = new AuthzToken();
authzToken.setAccessToken(accessToken);
Map<String, String> claimsMap = new HashMap<>();
claimsMap.put(Constants.USER_NAME, "scigap_admin");
claimsMap.put(Constants.API_METHOD_NAME, "/airavata/getAPIVersion");
authzToken.setClaimsMap(claimsMap);
DefaultXACMLPEP defaultXACMLPEP = new DefaultXACMLPEP(hostName + "/services/", username, password, configContext);
HashMap<String, String> metaDataMap = new HashMap();
boolean result = defaultXACMLPEP.getAuthorizationDecision(authzToken, metaDataMap);
System.out.println(result);
}
use of org.apache.axis2.context.ConfigurationContext in project carbon-business-process by wso2.
the class AxisServiceUtils method getOperationClient.
public static OperationClient getOperationClient(BPELMessageContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(partnerMessageContext.getService(), partnerMessageContext.getPort(), clientConfigCtx.getAxisConfiguration(), partnerMessageContext.getCaller());
anonymousService.engageModule(clientConfigCtx.getAxisConfiguration().getModule("UEPModule"));
anonymousService.getParent().addParameter(BPELConstants.HIDDEN_SERVICE_PARAM, "true");
ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
// get a reference to the DYNAMIC operation of the Anonymous Axis2 service
AxisOperation axisAnonymousOperation = anonymousService.getOperation(partnerMessageContext.isTwoWay() ? ServiceClient.ANON_OUT_IN_OP : ServiceClient.ANON_OUT_ONLY_OP);
Options clientOptions = cloneOptions(partnerMessageContext.getInMessageContext().getOptions());
clientOptions.setExceptionToBeThrownOnSOAPFault(false);
/* This value doesn't overrideend point config. */
clientOptions.setTimeOutInMilliSeconds(60000);
return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
use of org.apache.axis2.context.ConfigurationContext in project carbon-business-process by wso2.
the class AxisServiceUtils method invokeService.
public static void invokeService(BPELMessageContext partnerInvocationContext, ConfigurationContext configContext) throws AxisFault {
MessageContext mctx = partnerInvocationContext.getInMessageContext();
OperationClient opClient = getOperationClient(partnerInvocationContext, configContext);
mctx.getOptions().setParent(opClient.getOptions());
/*
Else we assume that the epr is not changed by the process.
In this case there's a limitation we cannot invoke the epr in the wsdl
(by assingning that epr by partnerlink assign) if there is a endpoint
configuration available for that particular service
*/
addCustomHeadersToMessageContext(mctx);
opClient.addMessageContext(mctx);
Options operationOptions = opClient.getOptions();
if (partnerInvocationContext.getUep().isAddressingEnabled()) {
// Currently we set the action manually, but this should be handled by
// addressing module it-self?
String action = getAction(partnerInvocationContext);
if (log.isDebugEnabled()) {
log.debug("Soap action: " + action);
}
operationOptions.setAction(action);
// TODO set replyto as well
// operationOptions.setReplyTo(mctx.getReplyTo());
}
if (partnerInvocationContext.getUep().getAddress() == null) {
partnerInvocationContext.getUep().setAddress(getEPRfromWSDL(partnerInvocationContext.getBpelServiceWSDLDefinition(), partnerInvocationContext.getService(), partnerInvocationContext.getPort()));
}
operationOptions.setTo(partnerInvocationContext.getUep());
opClient.execute(true);
if (partnerInvocationContext.isTwoWay()) {
partnerInvocationContext.setOutMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
partnerInvocationContext.setFaultMessageContext(opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE));
}
}
use of org.apache.axis2.context.ConfigurationContext in project carbon-business-process by wso2.
the class ServiceUtils method getOperationClient.
private static OperationClient getOperationClient(MessageContext partnerMessageContext, ConfigurationContext clientConfigCtx) throws AxisFault {
AxisService anonymousService = AnonymousServiceFactory.getAnonymousService(Constants.registrationService, Constants.REGISTRATION_PORT, clientConfigCtx.getAxisConfiguration(), Constants.HUMANTASK_COORDINATION_MODULE_NAME);
anonymousService.getParent().addParameter("hiddenService", "true");
ServiceGroupContext sgc = new ServiceGroupContext(clientConfigCtx, (AxisServiceGroup) anonymousService.getParent());
ServiceContext serviceCtx = sgc.getServiceContext(anonymousService);
AxisOperation axisAnonymousOperation = anonymousService.getOperation(ServiceClient.ANON_OUT_IN_OP);
Options clientOptions = cloneOptions(partnerMessageContext.getOptions());
clientOptions.setExceptionToBeThrownOnSOAPFault(false);
/* This value doesn't overrideend point config. */
clientOptions.setTimeOutInMilliSeconds(60000);
return axisAnonymousOperation.createClient(serviceCtx, clientOptions);
}
use of org.apache.axis2.context.ConfigurationContext in project carbon-business-process by wso2.
the class HumanTaskDeployer method init.
public void init(ConfigurationContext configurationContext) {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
log.info("Initializing HumanTask Deployer for tenant " + tenantId + ".");
try {
HumanTaskDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
createHumanTaskRepository(configurationContext);
HumanTaskServer humantaskServer = HumanTaskDeployerServiceComponent.getHumanTaskServer();
humanTaskStore = humantaskServer.getTaskStoreManager().createHumanTaskStoreForTenant(tenantId, configurationContext);
} catch (DeploymentException e) {
log.warn(String.format("Human Task Repository creation failed for tenant id [%d]", tenantId), e);
} catch (RegistryException e) {
log.warn("Initializing HumanTask Deployer failed for tenant " + tenantId, e);
}
}
Aggregations