org.apache.axis2.description.AxisBinding Java Examples

The following examples show how to use org.apache.axis2.description.AxisBinding. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an AxisOperation with the given data service operation object.
 * @see Operation
 * @see AxisOperation
 */
private AxisOperation createAxisOperationFromDSOperation(Operation operation,
		AxisBinding soap11Binding, AxisBinding soap12Binding,
		AxisBinding httpBinding) throws AxisFault {
	String opName = operation.getName();
	String requestName = operation.getRequestName();

	int index = opName.indexOf(":");
	if (index > -1) {
		opName = opName.substring(index + 1);
	}
	boolean hasResult = operation.getCallQuery().isHasResult()
			|| operation.isReturnRequestStatus();
	String description = operation.getDescription();
	return createAxisOperation(requestName, opName, HTTPConstants.HTTP_METHOD_POST, hasResult,
			soap11Binding, soap12Binding, httpBinding, description);
}
 
Example #2
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an AxisOperation with the given data service resource object.
 * @see Operation
 * @see AxisOperation
 */
private AxisOperation createAxisOperationFromDSResource(Resource resource,
                                                           AxisBinding soap11Binding, AxisBinding soap12Binding,
                                                           AxisBinding httpBinding) {
	Resource.ResourceID resourceId = resource.getResourceId();
	String method = resourceId.getMethod();
	String path = resourceId.getPath();
	String requestName = resource.getRequestName();
	String description = resource.getDescription();
	boolean hasResult = resource.getCallQuery().isHasResult()
			|| resource.isReturnRequestStatus();
	return createAxisOperation(requestName, path, method, hasResult, soap11Binding,
			soap12Binding, httpBinding, description);
}
 
Example #3
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with HTTP properties
 */
private AxisBindingOperation createDefaultHTTPBindingOperation(
		AxisOperation axisOp, String httpLocation, String httpMethod,
		AxisBinding httpBinding) {
	AxisBindingOperation httpBindingOperation = new AxisBindingOperation();
	httpBindingOperation.setAxisOperation(axisOp);
	httpBindingOperation.setName(axisOp.getName());
	httpBindingOperation.setParent(httpBinding);
	httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocation);
	httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethod);
	httpBinding.addChild(httpBindingOperation.getName(), httpBindingOperation);
	return httpBindingOperation;
}
 
Example #4
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with SOAP 1.2 properties
 */
private AxisBindingOperation createDefaultSOAP12BindingOperation(
		AxisOperation axisOp, String httpLocation, String inputAction,
		AxisBinding soap12Binding) {
	AxisBindingOperation soap12BindingOperation = new AxisBindingOperation();
	soap12BindingOperation.setAxisOperation(axisOp);
	soap12BindingOperation.setName(axisOp.getName());
	soap12BindingOperation.setParent(soap12Binding);
	soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
			httpLocation);
	soap12Binding.addChild(soap12BindingOperation.getName(), soap12BindingOperation);
	soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, inputAction);
	return soap12BindingOperation;
}
 
Example #5
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with SOAP 1.1 properties
 */
private AxisBindingOperation createDefaultSOAP11BindingOperation(
		AxisOperation axisOp, String httpLocation, String inputAction,
		AxisBinding soap11Binding) {
	AxisBindingOperation soap11BindingOperation = new AxisBindingOperation();
	soap11BindingOperation.setAxisOperation(axisOp);
	soap11BindingOperation.setName(axisOp.getName());
	soap11BindingOperation.setParent(soap11Binding);
	soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
			httpLocation);
	soap11Binding.addChild(soap11BindingOperation.getName(), soap11BindingOperation);
	soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, inputAction);
	return soap11BindingOperation;
}
 
Example #6
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default SOAP 1.1 properties
 */
private AxisBinding createDefaultSOAP11Binding(String name, String interfaceName) {
	AxisBinding soap11Binding = new AxisBinding();
	soap11Binding.setName(new QName(name + Java2WSDLConstants.BINDING_NAME_SUFFIX));
	soap11Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
	soap11Binding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, WSDL2Constants.HTTP_PROTOCAL);
	soap11Binding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
	soap11Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	soap11Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       soap11Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return soap11Binding;
}
 
Example #7
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default HTTP properties
 */
private AxisBinding createDefaultHTTPBinding(String name, String interfaceName) {
	AxisBinding httpBinding = new AxisBinding();
	httpBinding.setName(new QName(name + Java2WSDLConstants.HTTP_BINDING));
	httpBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
	httpBinding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	httpBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       httpBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return httpBinding;
}
 
Example #8
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default SOAP 1.2 properties
 */
private AxisBinding createDefaultSOAP12Binding(String name, String interfaceName) {
	AxisBinding soap12Binding = new AxisBinding();
	soap12Binding.setName(new QName(name + Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
	soap12Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
	soap12Binding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, WSDL2Constants.HTTP_PROTOCAL);
	soap12Binding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
	soap12Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	soap12Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       soap12Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return soap12Binding;
}
 
Example #9
Source File: SecurityDeploymentInterceptor.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void addPolicyToAllBindings(AxisService axisService, Policy policy)
        throws ServerException {
    try {
        if (policy.getId() == null) {
            // Generate an ID
            policy.setId(UUIDGenerator.getUUID());
        }
        Map endPointMap = axisService.getEndpoints();
        for (Object o : endPointMap.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            AxisEndpoint point = (AxisEndpoint) entry.getValue();
            AxisBinding binding = point.getBinding();
            String bindingName = binding.getName().getLocalPart();

            //only UTOverTransport is allowed for HTTP
            if (bindingName.endsWith("HttpBinding") &&
                    (!policy.getAttributes().containsValue("UTOverTransport"))) {
                continue;
            }
            binding.getPolicySubject().attachPolicy(policy);
            // Add the new policy to the registry
        }
    } catch (Exception e) {
        log.error("Error in adding security policy to all bindings", e);
        throw new ServerException("addPoliciesToService", e);
    }
}
 
Example #10
Source File: SecurityServiceAdmin.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * This method add Policy to service at the Registry. Does not add the
 * policy to Axis2. To all Bindings available
 *
 * @param axisService Service
 * @param policy      Policy
 * @throws org.wso2.carbon.utils.ServerException se
 */
public void addSecurityPolicyToAllBindings(AxisService axisService, Policy policy)
        throws ServerException {
    String serviceGroupId = axisService.getAxisServiceGroup().getServiceGroupName();
    try {
        if (policy.getId() == null) {
            policy.setId(UUIDGenerator.getUUID());
        }

        Map endPointMap = axisService.getEndpoints();
        for (Object o : endPointMap.entrySet()) {
            Map.Entry entry = (Map.Entry) o;
            AxisEndpoint point = (AxisEndpoint) entry.getValue();
            AxisBinding binding = point.getBinding();
            String bindingName = binding.getName().getLocalPart();

            //only UTOverTransport is allowed for HTTP
            if (bindingName.endsWith("HttpBinding") &&
                    (!policy.getAttributes().containsValue("UTOverTransport"))) {
                continue;
            }
            binding.getPolicySubject().attachPolicy(policy);

        }
    } catch (Exception e) {
        log.error("Error in adding security policy to all bindings", e);
        throw new ServerException("addPoliciesToService", e);
    }
}
 
Example #11
Source File: SecurityServiceAdmin.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void removeSecurityPolicyFromAllBindings(AxisService axisService, String uuid)
        throws ServerException {
    if (log.isDebugEnabled()) {
        log.debug("Removing  security policy from all bindings.");
    }
    Map endPointMap = axisService.getEndpoints();
    for (Object o : endPointMap.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        AxisEndpoint point = (AxisEndpoint) entry.getValue();
        AxisBinding binding = point.getBinding();
        if (binding.getPolicySubject().getAttachedPolicyComponent(uuid) != null) {
            binding.getPolicySubject().detachPolicyComponent(uuid);
        }
    }
}
 
Example #12
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Utility method for creating AxisOperation objects.
 */
private AxisOperation createAxisOperation(String operationName, String httpLocation,
		String method, boolean hasResult,
		AxisBinding soap11Binding, AxisBinding soap12Binding, AxisBinding httpBinding,
		String description) {
	AxisOperation axisOperation;
	if (hasResult) {
		axisOperation = new InOutAxisOperation(new QName(operationName));
		DBInOutMessageReceiver inoutMsgReceiver = new DBInOutMessageReceiver();
		axisOperation.setMessageReceiver(inoutMsgReceiver);
		axisOperation.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
	} else {
		axisOperation = new InOnlyAxisOperation(new QName(operationName));
		DBInOnlyMessageReceiver inonlyMsgReceiver = new DBInOnlyMessageReceiver();
		axisOperation.setMessageReceiver(inonlyMsgReceiver);
		axisOperation.setMessageExchangePattern(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY);
	}

	axisOperation.setStyle(WSDLConstants.STYLE_DOC);

	String opName = axisOperation.getName().getLocalPart();
	// Create a default SOAP 1.1 Binding operation
	AxisBindingOperation soap11BindingOperation = createDefaultSOAP11BindingOperation(
			axisOperation, httpLocation, "urn:" + opName, soap11Binding);

	// Create a default SOAP 1.2 Binding operation
	AxisBindingOperation soap12BindingOperation = createDefaultSOAP12BindingOperation(
			axisOperation, httpLocation, "urn:" + opName, soap12Binding);

	// Create a default HTTP Binding operation
	AxisBindingOperation httpBindingOperation = createDefaultHTTPBindingOperation(
			axisOperation, httpLocation, method, httpBinding);

       if(httpLocation.startsWith("/")){
           httpLocation = httpLocation.substring(1);
       }

       Pattern httpLocationPattern = WSDLUtil.getConstantFromHTTPLocationForResource(httpLocation, method);
       this.httpLocationTableForResource.put(httpLocationPattern, axisOperation);

	// Create the in and out axis messages for this operation
	AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
	if (inMessage != null) {
		inMessage.setName(operationName + Java2WSDLConstants.MESSAGE_SUFFIX);
		createAxisBindingMessage(soap11BindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
		createAxisBindingMessage(soap12BindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
		createAxisBindingMessage(httpBindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
	}

	if (axisOperation instanceof InOutAxisOperation) {
		AxisMessage outMessage =
                   axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
		if (outMessage != null) {
			outMessage.setName(operationName + Java2WSDLConstants.RESPONSE_MESSAGE);
			createAxisBindingMessage(soap11BindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
			createAxisBindingMessage(soap12BindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
			createAxisBindingMessage(httpBindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
		}
	}
	/* Set the fault message, only if operation returns a result*/
	if (hasResult) {
		AxisMessage faultMessage = new AxisMessage();
		faultMessage.setName(DBConstants.DS_FAULT_ELEMENT);
		faultMessage.setElementQName(new QName(DBConstants.WSO2_DS_NAMESPACE,
                DBConstants.DS_FAULT_ELEMENT));
		axisOperation.setFaultMessages(faultMessage);
		createAxisBindingMessage(soap11BindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
		createAxisBindingMessage(soap12BindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
		createAxisBindingMessage(httpBindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
	}

	axisOperation.setDocumentation(description);
	return axisOperation;
}
 
Example #13
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a set of default endpoints for this service
 */
private void createDefaultEndpoints(AxisService axisService, AxisBinding soap11Binding,
		AxisBinding soap12Binding, AxisBinding httpBinding) {
	Map<String, TransportInDescription> transportsIn = axisConfig.getTransportsIn();
	Iterator<TransportInDescription> iterator = transportsIn.values().iterator();
	while (iterator.hasNext()) {
		/*
		 * Used to indicate whether a HTTPEndpoint is needed. Http endpoint
		 * is needed only for http and https transports
		 */
		boolean needHttp = false;

		/* The prefix is used to generate endpoint names */
		String prefix = "";
		TransportInDescription transportIn = iterator.next();
		String transportInName = transportIn.getName();
		if (HTTP_TRANSPORT.equalsIgnoreCase(transportInName)) {
			needHttp = true;
		} else if (HTTPS_TRANSPORT.equalsIgnoreCase(transportInName)) {
			needHttp = true;
			prefix = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
		} else if (transportInName != null) {
			prefix = transportInName.toUpperCase();
		}

		/* Creates a default SOAP 1.1 endpoint */
		AxisEndpoint soap11Endpoint = new AxisEndpoint();
		String soap11EndpointName = prefix
				+ WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME;
		soap11Endpoint.setName(soap11EndpointName);
		soap11Endpoint.setBinding(soap11Binding);
		soap11Endpoint.setParent(axisService);
		soap11Endpoint.setTransportInDescription(transportInName);
		soap11Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
           soap11Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
		axisService.addEndpoint(soap11EndpointName, soap11Endpoint);

           /* setting soap11 endpoint as the default endpoint */
		axisService.setEndpointName(soap11EndpointName);

		/* Creates a default SOAP 1.2 endpoint */
		AxisEndpoint soap12Endpoint = new AxisEndpoint();
		String soap12EndpointName = prefix
				+ WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME;
		soap12Endpoint.setName(soap12EndpointName);
		soap12Endpoint.setBinding(soap12Binding);
		soap12Endpoint.setParent(axisService);
		soap12Endpoint.setTransportInDescription(transportInName);
		soap12Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
           soap12Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
		axisService.addEndpoint(soap12EndpointName, soap12Endpoint);

		/* Creates a HTTP endpoint if its http or https transport is used */
		if (needHttp) {
			AxisEndpoint httpEndpoint = new AxisEndpoint();
			String httpEndpointName = prefix
					+ WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME;
			httpEndpoint.setName(httpEndpointName);
			httpEndpoint.setBinding(httpBinding);
			httpEndpoint.setParent(axisService);
			httpEndpoint.setTransportInDescription(transportInName);
			httpEndpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
               httpEndpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
			axisService.addEndpoint(httpEndpointName, httpEndpoint);
		}
	}
}