PAOSRequest.java revision a688bcbb4bcff5398fdd29b86f83450257dc0df4
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The contents of this file are subject to the terms
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * of the Common Development and Distribution License
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * (the License). You may not use this file except in
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * compliance with the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You can obtain a copy of the License at
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * See the License for the specific language governing
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * permission and limitations under the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * When distributing Covered Code, include this CDDL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Header Notice in each file and include the License file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * If applicable, add the following below the CDDL Header,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * with the fields enclosed by brackets [] replaced by
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * your own identifying information:
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * $Id: PAOSRequest.java,v 1.3 2008/06/25 05:47:20 qcheng Exp $
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.liberty.ws.soapbinding.Utils;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The <code>PAOSRequest</code> class is used by a web application on
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * HTTP server side to construct a <code>PAOS</code> request message and send
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * it via an HTTP response to the user agent side.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @supported.all.api
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Constructs the <code>PAOSRequest</code> Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param responseConsumerURL the value of the responseConsumerURL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param service the value of the service attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param messageID the value of the messageID attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param mustUnderstand the value of the mustUnderstand attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param actor the value of the actor attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws PAOSException if <code>PAOSRequest</code> cannot be created.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public PAOSRequest(String responseConsumerURL, String service,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String messageID, Boolean mustUnderstand, String actor)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster this.responseConsumerURL = responseConsumerURL;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Constructs the <code>PAOSRequest</code> Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param element the Document Element of PAOS <code>Request</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws PAOSException if <code>PAOSRequest</code> cannot be created.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public PAOSRequest(Element element) throws PAOSException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Constructs the <code>PAOSRequest</code> Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param xmlString the XML String representation of this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws PAOSException if <code>PAOSRequest</code> cannot be created.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public PAOSRequest(String xmlString) throws PAOSException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster XMLUtils.toDOMDocument(xmlString, PAOSUtils.debug);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.bundle.getString("errorPAOSRequestElement"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster parseElement(xmlDocument.getDocumentElement());
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the value of the responseConsumerURL attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return the value of the responseConsumerURL attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #setResponseConsumerURL(String)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the value of the responseConsumerURL attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param responseConsumerURL the value of the responseConsumerURL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #getResponseConsumerURL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public void setResponseConsumerURL(String responseConsumerURL) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster this.responseConsumerURL = responseConsumerURL;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the value of the service attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return the value of the service attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #setService(String)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the value of the service attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param service the value of the service attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #getService
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the value of the messageID attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return the value of the messageID attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #setMessageID(String)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the value of the messageID attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param messageID the value of the messageID attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @see #getMessageID
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns value of <code>mustUnderstand</code> attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return value of <code>mustUnderstand</code> attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the value of the <code>mustUnderstand</code> attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param mustUnderstand the value of <code>mustUnderstand</code>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public void setMustUnderstand(Boolean mustUnderstand) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns value of <code>actor</code> attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return value of <code>actor</code> attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the value of <code>actor</code> attribute.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param actor the value of <code>actor</code> attribute
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns a String representation of this Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return a String representation of this Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception PAOSException if it could not create String object
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public String toXMLString() throws PAOSException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster return toXMLString(true, false);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns a String representation
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param includeNSPrefix determines whether or not the namespace
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * qualifier is prepended to the Element when converted
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param declareNS determines whether or not the namespace is declared
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * within the Element.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return a String representation of this Object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception PAOSException ,if it could not create String object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public String toXMLString(boolean includeNSPrefix,boolean declareNS)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(PAOSConstants.PAOS_PREFIX).append(":");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(" xmlns:").append(PAOSConstants.PAOS_PREFIX)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append("=\"").append(PAOSConstants.PAOS_NAMESPACE)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append("\" xmlns:").append(PAOSConstants.SOAP_ENV_PREFIX)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append("=\"").append(PAOSConstants.SOAP_ENV_NAMESPACE)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(" ").append(PAOSConstants.RESPONSE_CONSUMER_URL)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append("=\"").append(responseConsumerURL).append("\"")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append(" ").append(PAOSConstants.SERVICE).append("=\"")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(" ").append(PAOSConstants.MESSAGE_ID).append("=\"")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(" ").append(PAOSConstants.SOAP_ENV_PREFIX).append(":")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append(PAOSConstants.MUST_UNDERSTAND).append("=\"")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append(mustUnderstand.toString()).append("\"")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append(" ").append(PAOSConstants.SOAP_ENV_PREFIX).append(":")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append(PAOSConstants.PAOS_PREFIX).append(":");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private void parseElement(Element element) throws PAOSException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.parseElement:" +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster " Input is null.");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if (!PAOSConstants.REQUEST.equals(localName)) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.parseElement:" +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster " element local name should be " + PAOSConstants.REQUEST);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.bundle.getString("invalidPAOSRequest"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String namespaceURI = element.getNamespaceURI();
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if (!PAOSConstants.PAOS_NAMESPACE.equals(namespaceURI)) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.parseElement:" +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster " element namespace should be " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.bundle.getString("invalidPAOSNamesapce"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster responseConsumerURL = XMLUtils.getNodeAttributeValue(element,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster service = XMLUtils.getNodeAttributeValue(element,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster messageID = XMLUtils.getNodeAttributeValue(element,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String str = XMLUtils.getNodeAttributeValueNS(element,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSConstants.SOAP_ENV_NAMESPACE, PAOSConstants.MUST_UNDERSTAND);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new PAOSException(PAOSUtils.bundle.getString(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "invalidValueMustUnderstand"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster actor = XMLUtils.getNodeAttributeValueNS(element,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSConstants.SOAP_ENV_NAMESPACE, PAOSConstants.ACTOR);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private void validateData() throws PAOSException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.validateData: " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "responseConsumerURL is missing in the paos:Request");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new PAOSException(PAOSUtils.bundle.getString(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "missingResponseConsumerURLPAOSRequest"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.validateData: " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "service is missing in the paos:Request");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new PAOSException(PAOSUtils.bundle.getString(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "missingServicePAOSRequest"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.validateData: " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "mustUnderstand is missing in the paos:Request");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new PAOSException(PAOSUtils.bundle.getString(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "missingMustUnderstandPAOSRequest"));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster PAOSUtils.debug.message("PAOSRequest.validateData: " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "actor is missing in the paos:Request");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new PAOSException(PAOSUtils.bundle.getString(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "missingActorPAOSRequest"));