Java Code Examples for org.apache.axis2.description.Parameter#setParameterType()

The following examples show how to use org.apache.axis2.description.Parameter#setParameterType() . 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: TransportBuilderUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static Parameter toAxisParameter(TransportParameter parameter) throws XMLStreamException {
    Parameter p = new Parameter();
    p.setName(parameter.getName());

    OMElement paramElement = AXIOMUtil.stringToOM(parameter.getParamElement());
    p.setParameterElement(paramElement);

    if (paramElement.getFirstElement() != null) {
        p.setValue(paramElement);
        p.setParameterType(Parameter.OM_PARAMETER);
    } else {
        p.setValue(paramElement.getText());
        p.setParameterType(Parameter.TEXT_PARAMETER);
    }
    return p;
}
 
Example 2
Source File: RahasUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static Parameter getTokenCancelerConfigParameter() {

        OMFactory fac = OMAbstractFactory.getOMFactory();
        OMElement paramElem = fac.createOMElement(new QName("parameter"), null);
        paramElem.addAttribute(fac.createOMAttribute("name",
                null,
                TokenCancelerConfig.TOKEN_CANCELER_CONFIG.
                        getLocalPart()));
        paramElem.addAttribute(fac.createOMAttribute("type",
                null, Integer.toString(Parameter.OM_PARAMETER).
                        toString()));

        fac.createOMElement(TokenCancelerConfig.TOKEN_CANCELER_CONFIG,
                paramElem);
        Parameter param = new Parameter();
        param.setName(TokenCancelerConfig.TOKEN_CANCELER_CONFIG.getLocalPart());
        param.setParameterElement(paramElem);
        param.setValue(paramElem);
        param.setParameterType(Parameter.OM_PARAMETER);
        return param;
    }
 
Example 3
Source File: ParameterUtil.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Create an Axis2 parameter using the given OMElement
 *
 * @param parameterElement The OMElement of the parameter
 * @return Axis2 parameter with an the given OMElement
 * @throws AxisFault If the <code>parameterElement</code> is malformed
 */
public static Parameter createParameter(OMElement parameterElement) throws AxisFault {
    if(parameterElement.getParent() instanceof OMDocument) {
        parameterElement.detach();  //To enable a unified way of accessing the parameter via xpath.
    }
    Parameter parameter = new Parameter();
    //setting parameterElement
    parameter.setParameterElement(parameterElement);

    //setting parameter Name
    OMAttribute paraName = parameterElement.getAttribute(new QName("name"));
    if (paraName == null) {
        throw new AxisFault(Messages.getMessage(DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT));
    }
    parameter.setName(paraName.getAttributeValue());

    //setting parameter Value (the chiled elemnt of the parameter)
    OMElement paraValue = parameterElement.getFirstElement();
    if (paraValue != null) {
        parameter.setValue(parameterElement);
        parameter.setParameterType(Parameter.OM_PARAMETER);
    } else {
        String paratextValue = parameterElement.getText();
        parameter.setValue(paratextValue);
        parameter.setParameterType(Parameter.TEXT_PARAMETER);
    }

    //setting locking attribute
    OMAttribute paraLocked = parameterElement.getAttribute(new QName("locked"));
    parameter.setParameterElement(parameterElement);

    if (paraLocked != null) {
        String lockedValue = paraLocked.getAttributeValue();
        if ("true".equals(lockedValue)) {

            parameter.setLocked(true);

        } else {
            parameter.setLocked(false);
        }
    }
    return parameter;
}
 
Example 4
Source File: TransportBuilderUtils.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Processes transport parameters from the given configuration.
 * 
 * @param parameters An Iterator of OMElement which contains transport parameters.
 * @param parameterInclude ParameterInclude
 * @throws DeploymentException on error
 */
private static void processParameters(Iterator parameters,
                                         ParameterInclude parameterInclude) throws DeploymentException {

       if (parameters == null) {
           return;
       }

	while (parameters.hasNext()) {
		// this is to check whether some one has locked the parameter at the
		// top level
		OMElement parameterElement = (OMElement) parameters.next();
		Parameter parameter = new Parameter();
		// setting parameterElement
		parameter.setParameterElement(parameterElement);
		// setting parameter Name
		OMAttribute paramName = parameterElement.getAttribute(new QName(ATTRIBUTE_NAME));
		if (paramName == null) {
			throw new DeploymentException(Messages.getMessage(
					DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT, parameterElement.toString()));
		}
		parameter.setName(paramName.getAttributeValue());
		// setting parameter Value (the child element of the parameter)
		OMElement paramValue = parameterElement.getFirstElement();
		if (paramValue != null) {
			parameter.setValue(parameterElement);
			parameter.setParameterType(Parameter.OM_PARAMETER);
		} else {
			String paratextValue = parameterElement.getText();
			parameter.setValue(paratextValue);
			parameter.setParameterType(Parameter.TEXT_PARAMETER);
		}
		// setting locking attribute
		OMAttribute paramLocked = parameterElement.getAttribute(new QName(ATTRIBUTE_LOCKED));

		if (paramLocked != null) {
			String lockedValue = paramLocked.getAttributeValue();
			if (BOOLEAN_TRUE.equals(lockedValue)) {
				parameter.setLocked(true);
			} else {
				parameter.setLocked(false);
			}
		}
		try {
			parameterInclude.addParameter(parameter);
		} catch (AxisFault axisFault) {
			throw new DeploymentException(axisFault);
		}
	}
}
 
Example 5
Source File: RahasUtil.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
public static Parameter getSCTIssuerConfigParameter(String cryptoImpl,
                                                    Properties cryptoProperties,
                                                    int keyComputation,
                                                    String proofKeyType,
                                                    boolean addRequestedAttachedRef,
                                                    boolean addRequestedUnattachedRef) throws Exception {

    if (cryptoImpl == null || "".equals(cryptoImpl)) {
        throw new Exception("Crypto impl missing");
    }

    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement paramElem = fac.createOMElement(new QName("parameter"), null);
    paramElem.addAttribute(fac.createOMAttribute("name",
            null,
            SCTIssuerConfig.SCT_ISSUER_CONFIG.
                    getLocalPart()));

    paramElem.addAttribute(fac.createOMAttribute("type",
            null, Integer.toString(Parameter.OM_PARAMETER)));

    OMElement elem = fac.createOMElement(
            SCTIssuerConfig.SCT_ISSUER_CONFIG, paramElem);

    OMElement cryptoPropElem = fac.createOMElement(
            AbstractIssuerConfig.CRYPTO_PROPERTIES, elem);
    OMElement cryptoElem = fac.createOMElement(
            AbstractIssuerConfig.CRYPTO, cryptoPropElem);
    cryptoElem.addAttribute(fac.createOMAttribute("provider", null,
            cryptoImpl));

    Enumeration keysEnum = cryptoProperties.keys();
    while (keysEnum.hasMoreElements()) {
        String key = (String) keysEnum.nextElement();
        OMElement prop = fac.createOMElement(new QName("property"), cryptoElem);
        prop.addAttribute(fac.createOMAttribute("name", null, key));
        prop.setText(cryptoProperties.getProperty(key));
    }

    if (!(keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_PROVIDE_ENT ||
            keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_OWN_KEY ||
            keyComputation == AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_REQ_ENT)) {

        keyComputation = AbstractIssuerConfig.KeyComputation.KEY_COMP_USE_OWN_KEY;
    }

    OMElement keyCompElem = fac.createOMElement(
            AbstractIssuerConfig.KeyComputation.KEY_COMPUTATION, elem);
    keyCompElem.setText(Integer.toString(keyComputation));

    if (proofKeyType == null || "".equals(proofKeyType)) {
        proofKeyType = TokenIssuerUtil.BINARY_SECRET;
    } else if (!(TokenIssuerUtil.BINARY_SECRET.equals(proofKeyType)) ||
            TokenIssuerUtil.ENCRYPTED_KEY.equals(proofKeyType)) {
        throw new Exception("Invalid proof token type configuration : " + proofKeyType);
    }

    OMElement proofKeyTypeElem = fac.createOMElement(AbstractIssuerConfig.PROOF_KEY_TYPE, elem);
    proofKeyTypeElem.setText(proofKeyType);

    if (addRequestedAttachedRef) {
        fac.createOMElement(AbstractIssuerConfig.ADD_REQUESTED_ATTACHED_REF, elem);
    }

    if (addRequestedUnattachedRef) {
        fac.createOMElement(AbstractIssuerConfig.ADD_REQUESTED_UNATTACHED_REF, elem);
    }

    Parameter param = new Parameter();
    param.setName(SCTIssuerConfig.SCT_ISSUER_CONFIG.getLocalPart());
    param.setParameterType(Parameter.OM_PARAMETER);
    param.setValue(paramElem);
    param.setParameterElement(paramElem);
    return param;
}