Utils.java revision 905b8e215b24a1b5d547692cef530c0d2ab545c9
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Utils.java,v 1.9 2008/11/10 22:56:59 veiming Exp $
*
* Portions Copyright 2013-2016 ForgeRock AS.
*/
/**
* This class contains utility methods.
*
* @supported.api
*/
public class Utils {
static final String NAMESPACE_PREFIX_MAPPING_LIST_PROP =
"com.sun.identity.liberty.ws.jaxb.namespacePrefixMappingList";
static final String JAXB_PACKAGE_LIST_PROP =
"com.sun.identity.liberty.ws.jaxb.packageList";
static final String DEFAULT_JAXB_PACKAGES =
"com.sun.identity.liberty.ws.common.jaxb.soap:" +
"com.sun.identity.liberty.ws.common.jaxb.assertion:" +
"com.sun.identity.liberty.ws.common.jaxb.protocol:" +
"com.sun.identity.liberty.ws.common.jaxb.ac:" +
"com.sun.identity.liberty.ws.disco.jaxb:" +
"com.sun.identity.liberty.ws.disco.jaxb11:" +
"com.sun.identity.liberty.ws.disco.plugins.jaxb:" +
"com.sun.identity.liberty.ws.interaction.jaxb:" +
"com.sun.identity.liberty.ws.meta.jaxb:" +
"com.sun.identity.liberty.ws.paos.jaxb:" +
"com.sun.identity.liberty.ws.common.jaxb.ps:" +
"com.sun.identity.liberty.ws.common.jaxb.security:" +
"com.sun.identity.liberty.ws.soapbinding.jaxb:" +
"com.sun.identity.liberty.ws.soapbinding.jaxb11:" +
"com.sun.identity.liberty.ws.idpp.jaxb:" +
"com.sun.identity.liberty.ws.idpp.plugin.jaxb:" +
"com.sun.identity.liberty.ws.common.jaxb.secext:" +
"com.sun.identity.liberty.ws.common.jaxb.utility:" +
static final QName FAULT_CODE_SERVER =
static final String STALE_TIME_LIMIT_PROP =
"com.sun.identity.liberty.ws.soap.staleTimeLimit";
static final String SUPPORTED_ACTORS_PROP =
"com.sun.identity.liberty.ws.soap.supportedActors";
static final String LIBERTY_WSF_VERSION =
"com.sun.identity.liberty.wsf.version";
static final String MESSAGE_ID_CACHE_CLEANUP_INTERVAL_PROP =
"com.sun.identity.liberty.ws.soap.messageIDCacheCleanupInterval";
static {
try {
ex);
}
while(stz.hasMoreTokens()) {
if (debug.messageEnabled()) {
", prefix = " + prefix);
}
} else {
if (debug.warningEnabled()) {
"for Namespace Prefix Mapping List: " +
token);
}
}
}
}
} else {
}
if (debug.messageEnabled()) {
}
try {
} catch (JAXBException jaxbe) {
}
try {
if (debug.warningEnabled()) {
"limit. Default value will be used");
}
}
}
while(stz.hasMoreTokens()) {
}
}
}
tmpstr =
try {
if (debug.warningEnabled()) {
" get stale time limit. Default value " +
"will be used");
}
}
}
messageIDMap = new PeriodicCleanUpMap(
/ 1000) * 1000));
}
/**
* Returns JAXB namespace prefix mapping. Key is the namespace and value
* is the prefix.
*
* @return a Map of JAXB namespace prefix mapping
* @supported.api
*/
static public Map getNamespacePrefixMapping() {
return nsPrefix;
}
/**
* Returns a String of JAXB packages seperated by ":".
*
* @return a String of JAXB packages seperated by ":".
* @supported.api
*/
public static String getJAXBPackages() {
return jaxbPackages;
}
/**
* Converts Document to SOAPMessage
*
* @param doc the source Document
* @return SOAPMessage
* @throws SOAPBindingException if an error occurs while converting
* the document
* @supported.api
*/
throws SOAPBindingException {
try {
if (debug.messageEnabled()) {
xmlstr);
}
new ByteArrayInputStream(
} catch (Exception e) {
throw new SOAPBindingException(e.getMessage());
}
return msg;
}
/**
* Converts a list of JAXB objects to a list of
* <code>org.w3c.dom.Element</code>
*
* @param jaxbObjs a list of JAXB objects
* @return a list of <code>org.w3c.dom.Element</code>
* @throws JAXBException if an error occurs while converting JAXB objects.
*
* @supported.api
*/
throws JAXBException{
}
}
return result;
}
/**
* Converts a JAXB object to a <code>org.w3c.dom.Element</code>.
*
* @param jaxbObj a JAXB object
* @return a <code>org.w3c.dom.Element</code>
* @throws JAXBException if an error occurs while converting JAXB object.
* @supported.api
*/
throws JAXBException {
try {
m.setProperty("com.sun.xml.bind.namespacePrefixMapper",
new NamespacePrefixMapperImpl());
} catch(PropertyException ex) {
}
try {
}
return doc.getDocumentElement();
}
/**
* Converts a JAXB object to a <code>org.w3c.dom.Element</code>.
*
* @param jaxbObj a JAXB object
* @return a <code>org.w3c.dom.Element</code>
* @throws JAXBException if an error occurs while converting JAXB object.
* @supported.api
*/
boolean checkIdref) throws JAXBException {
try {
m.setProperty("com.sun.xml.bind.namespacePrefixMapper",
new NamespacePrefixMapperImpl());
} catch(PropertyException ex) {
}
if (!checkIdref) {
new DefaultValidationEventHandler() {
if (event instanceof NotIdentifiableEvent) {
return true;
}
return super.handleEvent(event);
}
});
}
try {
}
return doc.getDocumentElement();
}
/**
* Converts a list of <code>org.w3c.dom.Element</code> to a list of
* JAXB objects.
*
* @param elements a list of <code>org.w3c.dom.Element</code>
* @return a list of JAXB objects
* @throws JAXBException if an error occurs while converting
* <code>org.w3c.dom.Element</code>.
* @supported.api
*/
throws JAXBException{
}
}
return result;
}
/**
* Converts a <code>org.w3c.dom.Element</code> to a JAXB object.
*
* @param element a <code>org.w3c.dom.Element</code>.
* @return a JAXB object
* @throws JAXBException if an error occurs while converting
* <code>org.w3c.dom.Element</code>
* @supported.api
*/
throws JAXBException {
}
/**
* Converts a value of XML boolean type to Boolean object.
*
* @param str a value of XML boolean type
* @return a Boolean object
* @throws Exception if there is a syntax error
* @supported.api
*/
return null;
}
}
}
throw new Exception();
}
/**
* Converts a Boolean object to a String representing XML boolean.
*
* @param bool a Boolean object.
* @return a String representing the boolean value.
* @supported.api
*/
return "";
}
}
/**
* Converts a string value to a QName. The prefix of the string value
* is resolved to a namespace relative to the element.
*
* @param str the String to be converted.
* @param element the Element object.
* @return the QName Object.
* @supported.api
*/
return null;
}
if (index == -1) {
} else {
}
}
/**
* Gets the XML namespace URI that is mapped to the specified prefix, in
* the context of the DOM element e
*
* @param prefix The namespace prefix to map
* @param e The DOM element in which to calculate the prefix binding
* @return The XML namespace URI mapped to prefix in the context of e
*/
return e.lookupNamespaceURI(prefix);
}
/**
* Enforces message processiong rules defined in the spec.
*
* @param message a message
* @param requestMessageID the request messageID if we are checking a
* response message or null if we are checking a
* request message
* @param isServer true if this is a server
* @throws SOAPBindingException if the message violates rules on client.
* @throws SOAPFaultException if the message violates rules on server.
*/
boolean isServer)
throws SOAPBindingException, SOAPFaultException {
}
}
}
/**
* Enforces message Correlation header processiong rules defined
* in the spec.
*
* @param corrH a Correlation header
* @param requestMessageID the request messageID if we are checking a
* response message or null if we are checking a
* request message
* @param isServer true if this is a server
* @throws SOAPBindingException if the Correlation header violates rules
* on client side
* @throws SOAPFaultException if the Correlation header violates rules
* on server side
*/
throws SOAPBindingException, SOAPFaultException {
if (isServer) {
new SOAPFaultDetail(
} else {
throw new SOAPBindingException(
}
}
try {
} catch (SOAPFaultException sfe) {
throw sfe;
}
if (isServer) {
} else {
}
}
if (prevMsgIDTime != null &&
if (isServer) {
} else {
}
} else {
synchronized (messageIDMap) {
if (debug.messageEnabled()) {
"messageID: " + messageID);
}
}
}
if (isServer) {
new SOAPFaultDetail(
} else {
}
}
}
/**
* Enforces message Provider header processing rules defined
* in the spec.
*
* @param provH a Correlation header
* @param messageID the messageID in Correlation header
* @param isServer true if this is a server
* @throws SOAPBindingException if the Provider header violates rules
* on client side
* @throws SOAPFaultException if the Provider header violates rules
* on server side
*/
throws SOAPBindingException, SOAPFaultException {
return;
}
try {
} catch (SOAPFaultException sfe) {
throw sfe;
}
}
}
}
}
/**
* Enforces message Processing Context header processiong rules defined
* in the spec.
* @param procH a Processing Context header
* @param messageID the messageID in Correlation header
* @param isServer true if this is a server
* @throws SOAPBindingException if the Processing Context header
* violates rules on client side
* @throws SOAPFaultException if the Processing Context header violates
* rules on server side
*/
throws SOAPBindingException, SOAPFaultException {
return;
}
try {
} catch (SOAPFaultException sfe) {
throw sfe;
}
if (isServer) {
} else {
throw new SOAPBindingException(
}
}
/**
* Enforces message Consent header processiong rules defined in the spec.
*
* @param consH a Consent header
* @param messageID the messageID in Correlation header
* @param isServer true if this is a server
* @throws SOAPBindingException if the Consent header violates rules on
* client side
* @throws SOAPFaultException if the Consent header violates rules
* on server side
*/
return;
}
try {
} catch (SOAPFaultException sfe) {
throw sfe;
}
}
/**
* Enforces message Usage Directive header processiong rules defined in
* the spec.
*
* @param usagH a Usage Directive header
* @param messageID the messageID in Correlation header
* @param isServer true if this is a server
* @throws SOAPBindingException if the Usage Directive header violates
* rules on client side
* @throws SOAPFaultException if the Usage Directive header violates
* rules on server side
*/
throws SOAPBindingException, SOAPFaultException {
return;
}
try {
} catch (SOAPFaultException sfe) {
throw sfe;
}
}
/**
* Checks 'actor' and 'mustUnderstand' attribute of a header.
*
* @param actor the value of 'actor' attribute of a header.
* @param mustUnderstand the value of 'mustUnderstand' attribute of a
* header.
* @param messageID the messageID in Correlation header.
* @param isServer true if this is a server.
* @throws SOAPBindingException if the actor and mustUnderstand violates
* rules on client side
* @throws SOAPFaultException if the actor and mustUnderstand violates
* rules on server side
*/
throws SOAPBindingException, SOAPFaultException {
if (isServer) {
} else {
throw new SOAPBindingException(
}
}
if (isServer) {
} else {
throw new SOAPBindingException(
}
}
}
/**
* Gets localized string from resource bundle.
*
* @param key a key to a resource bundle
* @param params parameters to MessageFormat
* @return a localized string.
* @supported.api
*/
}
/**
* Returns the default web services version.
*
* @return the default web services version.
*/
public static String getDefaultWSFVersion() {
}
}