SMSSchema.java revision ff4c630f492b46e84d16909de750fd1308e2e81d
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 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: SMSSchema.java,v 1.11 2009/06/05 19:25:27 veiming Exp $
*
*/
/*
* Portions Copyrighted 2010-2015 ForgeRock AS.
*/
/**
* This class provides methods to obtain service schema and plugin schema from
* XML documents.
*/
public class SMSSchema {
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
"\n<ServicesConfiguration><Service name=\"";
private static final String SCHEMA_SUFFIX =
"</Service></ServicesConfiguration>";
"\n<ServicesConfiguration><Service name=\"";
private static final String PLUGIN_SUFFIX =
"</Service></ServicesConfiguration>";
// Pointer to the complete document
private String serviceName;
/**
* Constructor to instantiate SMSSchema with a DOM's Document. Using this
* constructor would use the first <code>Service
* </code> element.
*
* @param document
* service schema in XML DOM
* @throws SMSException
*/
version = getServiceVersion();
}
/**
* Constructor to instantiate SMSSchema with Document
*
* @param serviceName
* name of the service
* @param document
* service schema in XML DOM
* @throws SMSException
*/
this(document);
this.serviceName = serviceName;
}
throws SMSException {
this(serviceName, document);
}
/**
* Constructor to instantiate SMSSchema with XML input stream.
*
* @param serviceName
* name of the service
* @param in
* service schema xml
* @throws SMSException
*/
this(in);
this.serviceName = serviceName;
}
/**
* Constructor to instantiate SMSSchema with XML input stream. Using this
* constructor would use the first <code>Service
* </code> element.
*
* @param in
* service schema xml
* @throws SMSException
*/
this(getXMLDocument(in));
}
if (serviceName == null) {
}
return (serviceName);
}
}
return (version);
}
// Get the first service element
}
// Get the requested attribute value
}
return (value);
}
+ "No Service node not found in XML input.");
}
// Get the required service node
boolean foundNode = false;
for (int i = 0; i < nodeLen; i++) {
.equalsIgnoreCase(version)) {
foundNode = true;
break;
}
}
if (!foundNode) {
+ "Service not found :" + serviceName);
}
return (parent);
}
/**
* Method returns the XML schema for the given service name in a String
* format that can stored in a directory.
*
* @param serviceName
* name of the service
* @return service schema in serialized String format
* @throws SMSException
*/
this.serviceName = serviceName;
this.serviceName = oldServiceName;
return (schema);
}
/**
* Method returns the XML schema for the service in a String format that can
* stored in a directory.
*
* @return service schema in serialized String format
* @throws SMSException
*/
// Get Service Schema node
== null)
{
"IUMSConstants.SMS_SMSSchema_no_service_element", null));
}
}
/**
* Method returns the XML plugin schema for the given service name and
* plugin name in a String format that can stored in a directory.
*
* @param serviceName
* name of the service
* @param pluginName
* name of the plugin schema name
* @return service plugin schema in serialized String format
* @throws SMSException
*/
throws SMSException {
this.serviceName = serviceName;
this.serviceName = oldServiceName;
return (schema);
}
/**
* Method returns the XML plugin schema for the given plugin name in a
* String format that can stored in a directory.
*
* @param pluginName
* name of the plugin schema name
* @return service plugin schema in serialized String format
* @throws SMSException
*/
}
}
// Since the plugin schema node is not found, throw an exception
}
/**
* Method returns the XML plugin schema for the given plugin name in a
* String format that can stored in a directory.
*
* @param pluginName plugin schema name
* @return service plugin schema in serialized String format
* @throws SMSException
*/
}
// ---------- static methods ----------------------
}
+ "\"></Service></ServicesConfiguration>");
}
return "";
}
answer += getNodeValue(a);
for (int i = 0; i < nodeLen; i++) {
else
}
return (answer);
}
int attrLen = 0;
for (int i = 0; i < attrLen; i++) {
+ "\" ";
}
}
return (answer);
}
return ("");
}
throws SchemaException, SMSException {
}
throws SchemaException, SMSException {
return (getXMLDocument(in, true));
}
throws SchemaException, SMSException {
try {
return (doc);
} catch (SAXParseException pe) {
} catch (SAXException sax) {
} catch (ParserConfigurationException pc) {
} catch (IOException ioe) {
}
}
throws SMSException {
}
xmlEncoding = "UTF-8";
}
try {
}
return in;
}
Document getDocument() {
return document;
}
/**
* The method escapes '&', '<', '>', '"', '''
*/
return txt;
}
if (len == 0) {
return txt;
}
for (int i = 0; i < len; i++) {
switch (c) {
case '&':
break;
case '<':
break;
case '>':
break;
case '\"':
break;
case '\'':
break;
case '/':
break;
case '\u00A0':
break;
default:
}
}
}
/**
* The method reverses the escape sequence "/" to the character "/".
*/
return txtName;
}
if (len == 0) {
return txtName;
}
int indx;
if (indx >= 0) {
}
}
return (txtName);
}
}