Search in sources :

Example 86 with ConfigurationContext

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);
}
Also used : DefaultOAuthClient(org.apache.airavata.service.security.oauth.DefaultOAuthClient) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) DefaultXACMLPEP(org.apache.airavata.service.security.xacml.DefaultXACMLPEP) HashMap(java.util.HashMap) AuthzToken(org.apache.airavata.model.security.AuthzToken) OAuth2TokenValidationResponseDTO(org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO)

Example 87 with ConfigurationContext

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);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 88 with ConfigurationContext

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));
    }
}
Also used : OperationClient(org.apache.axis2.client.OperationClient) Options(org.apache.axis2.client.Options) BPELMessageContext(org.wso2.carbon.bpel.core.ode.integration.BPELMessageContext) MessageContext(org.apache.axis2.context.MessageContext)

Example 89 with ConfigurationContext

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);
}
Also used : Options(org.apache.axis2.client.Options) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) ServiceContext(org.apache.axis2.context.ServiceContext) AxisService(org.apache.axis2.description.AxisService)

Example 90 with ConfigurationContext

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);
    }
}
Also used : HumanTaskServer(org.wso2.carbon.humantask.core.HumanTaskServer) DeploymentException(org.apache.axis2.deployment.DeploymentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException)

Aggregations

ConfigurationContext (org.apache.axis2.context.ConfigurationContext)143 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)97 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)58 Parameter (org.apache.axis2.description.Parameter)52 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)52 Test (org.junit.Test)48 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)45 OMElement (org.apache.axiom.om.OMElement)42 AxisFault (org.apache.axis2.AxisFault)27 AxisService (org.apache.axis2.description.AxisService)25 EndpointReference (org.apache.axis2.addressing.EndpointReference)23 MessageContext (org.apache.synapse.MessageContext)22 Options (org.apache.axis2.client.Options)21 MessageContext (org.apache.axis2.context.MessageContext)21 ServiceContext (org.apache.axis2.context.ServiceContext)15 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 HashMap (java.util.HashMap)14 TransportOutDescription (org.apache.axis2.description.TransportOutDescription)14 ArrayList (java.util.ArrayList)13