XMLSignatureInputDebugger.java revision 0
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Class XMLSignatureInputDebugger
*
* @author $Author: raul $
*/
public class XMLSignatureInputDebugger {
/** Field _xmlSignatureInput */
private Set _xpathNodeSet;
private Set _inclusiveNamespaces;
/** Field _doc */
/** Field _writer */
// J-
// public static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC
// \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><style
// #FFFFFF; font-weight: bold; } .EXCLUDED { color: #666666;
// background-color: #999999; } .INCLUDEDINCLUSIVENAMESPACE { color:
// #0000FF; background-color: #FFFFFF; font-weight: bold; font-style:
// italic; } .EXCLUDEDINCLUSIVENAMESPACE { color: #0000FF; background-color:
// #999999; font-style: italic; } --> </style> </head><body
// bgcolor=\"#999999\"><pre>";
/** The HTML Prefix* */
static final String HTMLPrefix = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
+ "<html>\n"
+ "<head>\n"
+ "<title>Caninical XML node set</title>\n"
+ "<!-- \n"
+ ".INCLUDED { \n"
+ " color: #000000; \n"
+ " background-color: \n"
+ " #FFFFFF; \n"
+ " font-weight: bold; } \n"
+ ".EXCLUDED { \n"
+ " color: #666666; \n"
+ " background-color: \n"
+ " #999999; } \n"
+ ".INCLUDEDINCLUSIVENAMESPACE { \n"
+ " color: #0000FF; \n"
+ " background-color: #FFFFFF; \n"
+ " font-weight: bold; \n"
+ " font-style: italic; } \n"
+ ".EXCLUDEDINCLUSIVENAMESPACE { \n"
+ " color: #0000FF; \n"
+ " background-color: #999999; \n"
+ " font-style: italic; } \n"
+ "--> \n"
+ "</style> \n"
+ "</head>\n"
+ "<body bgcolor=\"#999999\">\n"
+ "<h1>Explanation of the output</h1>\n"
+ "<p>The following text contains the nodeset of the given Reference before it is canonicalized. There exist four different styles to indicate how a given node is treated.</p>\n"
+ "<ul>\n"
+ "<li class=\"INCLUDED\">A node which is in the node set is labeled using the INCLUDED style.</li>\n"
+ "<li class=\"EXCLUDED\">A node which is <em>NOT</em> in the node set is labeled EXCLUDED style.</li>\n"
+ "<li class=\"INCLUDEDINCLUSIVENAMESPACE\">A namespace which is in the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
+ "<li class=\"EXCLUDEDINCLUSIVENAMESPACE\">A namespace which is in NOT the node set AND in the InclusiveNamespaces PrefixList is labeled using the INCLUDEDINCLUSIVENAMESPACE style.</li>\n"
+ "</ul>\n" + "<h1>Output</h1>\n" + "<pre>\n";
/** HTML Suffix * */
static final String HTMLIncludedInclusiveNamespacePrefix = "<span class=\"INCLUDEDINCLUSIVENAMESPACE\">";
static final String HTMLExcludedInclusiveNamespacePrefix = "<span class=\"EXCLUDEDINCLUSIVENAMESPACE\">";
private static final int NODE_BEFORE_DOCUMENT_ELEMENT = -1;
private static final int NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT = 0;
private static final int NODE_AFTER_DOCUMENT_ELEMENT = 1;
// J+
private XMLSignatureInputDebugger() {
// do nothing
}
/**
* Constructor XMLSignatureInputDebugger
*
* @param xmlSignatureInput the signatur to pretty print
*/
public XMLSignatureInputDebugger(
if (!xmlSignatureInput.isNodeSet()) {
this._xpathNodeSet = null;
} else {
}
}
/**
* Constructor XMLSignatureInputDebugger
*
* @param xmlSignatureInput the signatur to pretty print
* @param inclusiveNamespace
*/
public XMLSignatureInputDebugger(
this(xmlSignatureInput);
}
/**
* Method getHTMLRepresentation
*
* @return The HTML Representation.
* @throws XMLSignatureException
*/
return HTMLPrefix + "<blink>no node set, sorry</blink>"
+ HTMLSuffix;
}
{
// get only a single node as anchor to fetch the owner document
}
try {
this._writer = new StringWriter();
this.canonicalizeXPathNodeSet(this._doc);
} catch (IOException ex) {
} finally {
this._xpathNodeSet = null;
}
}
/**
* Method canonicalizeXPathNodeSet
*
* @param currentNode
* @throws XMLSignatureException
* @throws IOException
*/
throws XMLSignatureException, IOException {
switch (currentNodeType) {
case Node.DOCUMENT_TYPE_NODE:
default:
break;
case Node.ENTITY_NODE:
case Node.NOTATION_NODE:
case Node.DOCUMENT_FRAGMENT_NODE:
case Node.ATTRIBUTE_NODE:
throw new XMLSignatureException("empty");
case Node.DOCUMENT_NODE:
for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
.getNextSibling()) {
}
break;
case Node.COMMENT_NODE:
} else {
}
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
}
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
}
} else {
}
break;
} else {
}
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
}
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
}
} else {
}
break;
case Node.CDATA_SECTION_NODE:
} else {
}
.getNextSibling()) {
/*
* The XPath data model allows to select only the first of a
* sequence of mixed text and CDATA nodes. But we must output
* them all, so we must search:
*
*/
}
} else {
}
break;
case Node.ELEMENT_NODE:
} else {
}
} else {
}
// we output all Attrs which are available
for (int i = 0; i < attrsLength; i++) {
}
for (int i = 0; i < attrsLength; i++) {
.getName());
if (included) {
if (inclusive) {
// included and inclusive
this._writer
} else {
// included and not inclusive
}
} else {
if (inclusive) {
// excluded and inclusive
this._writer
} else {
// excluded and not inclusive
}
}
if (included) {
if (inclusive) {
// included and inclusive
this._writer
} else {
// included and not inclusive
}
} else {
if (inclusive) {
// excluded and inclusive
this._writer
} else {
// excluded and not inclusive
}
}
}
} else {
}
} else {
}
// traversal
for (Node currentChild = currentNode.getFirstChild(); currentChild != null; currentChild = currentChild
.getNextSibling()) {
}
} else {
}
} else {
}
break;
}
}
/**
* Checks whether a Comment or ProcessingInstruction is before or after the
* document element. This is needed for prepending or appending "\n"s.
*
* @param currentNode
* comment or pi to check
* @return NODE_BEFORE_DOCUMENT_ELEMENT,
* NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or
* NODE_AFTER_DOCUMENT_ELEMENT
* @see #NODE_BEFORE_DOCUMENT_ELEMENT
* @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
* @see #NODE_AFTER_DOCUMENT_ELEMENT
*/
if (currentNode == null) {
}
}
if (documentElement == null) {
}
if (documentElement == currentNode) {
}
if (x == documentElement) {
return NODE_BEFORE_DOCUMENT_ELEMENT;
}
}
return NODE_AFTER_DOCUMENT_ELEMENT;
}
/**
* Normalizes an {@link Attr}ibute value
*
* The string value of the node is modified by replacing
* <UL>
* <LI>all ampersands (&) with <CODE>&amp;</CODE></LI>
* <LI>all open angle brackets (<) with <CODE>&lt;</CODE></LI>
* <LI>all quotation mark characters with <CODE>&quot;</CODE></LI>
* <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD,
* with character references. The character references are written in
* uppercase hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE>
* is represented by the character reference <CODE>&#xD;</CODE>)</LI>
* </UL>
*
* @param name
* @param value
* @throws IOException
*/
throws IOException {
for (int i = 0; i < length; i++) {
switch (c) {
case '&':
break;
case '<':
break;
case '"':
break;
case 0x09: // '\t'
break;
case 0x0A: // '\n'
break;
case 0x0D: // '\r'
break;
default:
break;
}
}
}
/**
* Normalizes a {@link org.w3c.dom.Comment} value
*
* @param currentPI
* @throws IOException
*/
throws IOException {
return;
}
for (int i = 0; i < length; i++) {
switch (c) {
case 0x0D:
break;
case ' ':
break;
case '\n':
break;
default:
break;
}
}
for (int i = 0; i < length; i++) {
switch (c) {
case 0x0D:
break;
default:
break;
}
}
}
}
/**
* Method outputCommentToWriter
*
* @param currentComment
* @throws IOException
*/
throws IOException {
if (currentComment == null) {
return;
}
for (int i = 0; i < length; i++) {
switch (c) {
case 0x0D:
break;
case ' ':
break;
case '\n':
break;
default:
break;
}
}
}
/**
* Method outputTextToWriter
*
* @param text
* @throws IOException
*/
return;
}
for (int i = 0; i < length; i++) {
switch (c) {
case '&':
break;
case '<':
break;
case '>':
break;
case 0xD:
break;
case ' ':
break;
case '\n':
break;
default:
break;
}
}
}
}