Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14
In directory sc8-pr-cvs1:/tmp/cvs-serv10728/src/java/org/neuclear/xml/c14
Modified Files:
Canonicalizer.java CanonicalizerWithComments.java
CanonicalizerWithoutSignature.java
Log Message:
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Index: Canonicalizer.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/Canonicalizer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Canonicalizer.java 11 Nov 2003 21:18:07 -0000 1.2
--- Canonicalizer.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 8,11 ****
--- 8,17 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 pelle
+ * EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
+ * Otherwise You will Finaliate.
+ * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
+ * This should hopefully make everything more stable (and secure).
+ *
* Revision 1.2 2003/11/11 21:18:07 pelle
* Further vital reshuffling.
***************
*** 122,126 ****
}
! protected Canonicalizer( String xpath) {
super(xpath);
--- 128,132 ----
}
! protected Canonicalizer( final String xpath) {
super(xpath);
***************
*** 147,151 ****
* @throws IOException
*/
! public byte [] canonicalize(Object node) throws IOException {
init();
write(node);
--- 153,157 ----
* @throws IOException
*/
! public final byte [] canonicalize(final Object node) throws IOException {
init();
write(node);
***************
*** 161,171 ****
* @throws IOException
*/
! public byte[] canonicalizeSubset(Node node, String xpath) throws IOException {
init();
! XPath xpathSelector = DocumentHelper.createXPath(xpath);
! Map nsmap = new HashMap();
nsmap.put("ietf", "http://www.ietf.org");
xpathSelector.setNamespaceURIs(nsmap);
! List nl = xpathSelector.selectNodes(node);
write(nl);
return getBytes();
--- 167,177 ----
* @throws IOException
*/
! public final byte[] canonicalizeSubset(final Node node, final String xpath) throws IOException {
init();
! final XPath xpathSelector = DocumentHelper.createXPath(xpath);
! final Map nsmap = new HashMap();
nsmap.put("ietf", "http://www.ietf.org");
xpathSelector.setNamespaceURIs(nsmap);
! final List nl = xpathSelector.selectNodes(node);
write(nl);
return getBytes();
***************
*** 178,182 ****
}
! private void write(Object obj) throws IOException {
if (obj instanceof Node)
writeNode((Node) obj);
--- 184,188 ----
}
! private void write(final Object obj) throws IOException {
if (obj instanceof Node)
writeNode((Node) obj);
***************
*** 184,190 ****
writeNode(((ElementProxy) obj).getElement());
} else if (obj instanceof List) {
! Iterator iter = ((List) obj).iterator();
while (iter.hasNext()) {
! Node node = (Node) iter.next();
write(node);
}
--- 190,196 ----
writeNode(((ElementProxy) obj).getElement());
} else if (obj instanceof List) {
! final Iterator iter = ((List) obj).iterator();
while (iter.hasNext()) {
! final Node node = (Node) iter.next();
write(node);
}
***************
*** 194,202 ****
}
! private void writeNode(Node node) throws IOException {
if (!matches(node))
return;
! int nodeType = node.getNodeType();
switch (nodeType) {
--- 200,208 ----
}
! private void writeNode(final Node node) throws IOException {
if (!matches(node))
return;
! final int nodeType = node.getNodeType();
switch (nodeType) {
***************
*** 238,242 ****
}
! private void outputLF(Node node) throws IOException {
if (node.getParent() == null && notfirst) {
writer.write(LF);
--- 244,248 ----
}
! private void outputLF(final Node node) throws IOException {
if (node.getParent() == null && notfirst) {
writer.write(LF);
***************
*** 244,258 ****
}
! private void writeDocType(DocumentType documentType) {
}
! private void writeDocument(Document document) throws IOException {
for (int i = 0, size = document.nodeCount(); i < size; i++) {
! Node node = document.node(i);
write(node);
}
}
! private void writeComment(Comment comment) throws IOException {
outputLF(comment);
writer.write("<!--");
--- 250,264 ----
}
! private void writeDocType(final DocumentType documentType) {
}
! private void writeDocument(final Document document) throws IOException {
for (int i = 0, size = document.nodeCount(); i < size; i++) {
! final Node node = document.node(i);
write(node);
}
}
! private void writeComment(final Comment comment) throws IOException {
outputLF(comment);
writer.write("<!--");
***************
*** 261,265 ****
}
! private void writeProcessingInstruction(ProcessingInstruction processingInstruction) throws IOException {
outputLF(processingInstruction);
writer.write("<?");
--- 267,271 ----
}
! private void writeProcessingInstruction(final ProcessingInstruction processingInstruction) throws IOException {
outputLF(processingInstruction);
writer.write("<?");
***************
*** 272,282 ****
}
! private void writeEntity(Entity entity) throws IOException {
! String text = entity.getText();
! int hashLoc = text.indexOf('#');
writer.write(entity.getText()); //TODO entities need to be expanded
}
! private void writeAttribute(Attribute attribute) throws IOException {
writer.write(" ");
writer.write(attribute.getQualifiedName());
--- 278,288 ----
}
! private void writeEntity(final Entity entity) throws IOException {
! final String text = entity.getText();
! final int hashLoc = text.indexOf('#');
writer.write(entity.getText()); //TODO entities need to be expanded
}
! private void writeAttribute(final Attribute attribute) throws IOException {
writer.write(" ");
writer.write(attribute.getQualifiedName());
***************
*** 288,301 ****
}
! private void writeElement(Element element) throws IOException {
outputLF(element);
! String qualifiedName = element.getQualifiedName();
writer.write("<");
writer.write(qualifiedName);
! int previouslyDeclaredNamespaces = namespaceStack.size();
! Namespace ns = element.getNamespace();
! TreeMap sorted = new TreeMap();
if (isNamespaceDeclaration(ns)) {
namespaceStack.push(ns);
--- 294,307 ----
}
! private void writeElement(final Element element) throws IOException {
outputLF(element);
! final String qualifiedName = element.getQualifiedName();
writer.write("<");
writer.write(qualifiedName);
! final int previouslyDeclaredNamespaces = namespaceStack.size();
! final Namespace ns = element.getNamespace();
! final TreeMap sorted = new TreeMap();
if (isNamespaceDeclaration(ns)) {
namespaceStack.push(ns);
***************
*** 305,311 ****
}
! Iterator nsiter = element.additionalNamespaces().iterator();
while (nsiter.hasNext()) {
! Namespace namespace = (Namespace) nsiter.next();
if (!namespaceStack.contains(namespace)) {
writeNamespace(namespace, sorted);
--- 311,317 ----
}
! final Iterator nsiter = element.additionalNamespaces().iterator();
while (nsiter.hasNext()) {
! final Namespace namespace = (Namespace) nsiter.next();
if (!namespaceStack.contains(namespace)) {
writeNamespace(namespace, sorted);
***************
*** 317,321 ****
writer.write(">");
for (int i = 0, size = element.nodeCount(); i < size; i++) {
! Node node = element.node(i);
write(node);
}
--- 323,327 ----
writer.write(">");
for (int i = 0, size = element.nodeCount(); i < size; i++) {
! final Node node = element.node(i);
write(node);
}
***************
*** 333,337 ****
}
! private void writeNamespace(Namespace namespace, TreeMap sorted) throws IOException {
if (namespace != null) {
sorted.put("0" + namespace.getPrefix(), namespace);
--- 339,343 ----
}
! private void writeNamespace(final Namespace namespace, final TreeMap sorted) throws IOException {
if (namespace != null) {
sorted.put("0" + namespace.getPrefix(), namespace);
***************
*** 339,343 ****
}
! private void writeAttributes(Element element, TreeMap sorted) throws IOException {
// I do not yet handle the case where the same prefix maps to
--- 345,349 ----
}
! private void writeAttributes(final Element element, final TreeMap sorted) throws IOException {
// I do not yet handle the case where the same prefix maps to
***************
*** 349,358 ****
for (int i = 0, size = element.attributeCount(); i < size; i++) {
! Attribute attribute = element.attribute(i);
sorted.put(attribute.getNamespaceURI() + ":" + attribute.getName(), attribute);
! Namespace ns = attribute.getNamespace();
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! String prefix = ns.getPrefix();
! String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
writeNamespace(ns, sorted);
--- 355,364 ----
for (int i = 0, size = element.attributeCount(); i < size; i++) {
! final Attribute attribute = element.attribute(i);
sorted.put(attribute.getNamespaceURI() + ":" + attribute.getName(), attribute);
! final Namespace ns = attribute.getNamespace();
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! final String prefix = ns.getPrefix();
! final String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
writeNamespace(ns, sorted);
***************
*** 362,369 ****
}
! Iterator iter = sorted.keySet().iterator();
while (iter.hasNext()) {
! String name = (String) iter.next();
! Node node = (Node) sorted.get(name);
if (node instanceof Attribute)
writeAttribute((Attribute) node);
--- 368,375 ----
}
! final Iterator iter = sorted.keySet().iterator();
while (iter.hasNext()) {
! final String name = (String) iter.next();
! final Node node = (Node) sorted.get(name);
if (node instanceof Attribute)
writeAttribute((Attribute) node);
***************
*** 375,380 ****
}
! private void writeNSAttribute(Namespace namespace) throws IOException {
! String prefix = namespace.getPrefix();
writer.write(" xmlns");
if (prefix != null && prefix.length() > 0) {
--- 381,386 ----
}
! private void writeNSAttribute(final Namespace namespace) throws IOException {
! final String prefix = namespace.getPrefix();
writer.write(" xmlns");
if (prefix != null && prefix.length() > 0) {
***************
*** 387,393 ****
}
! private boolean isNamespaceDeclaration(Namespace ns) {
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! String uri = ns.getURI();
if (uri != null) {//&& uri.length() > 0 ) {
if (!namespaceStack.contains(ns)) {
--- 393,399 ----
}
! private boolean isNamespaceDeclaration(final Namespace ns) {
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
! final String uri = ns.getURI();
if (uri != null) {//&& uri.length() > 0 ) {
if (!namespaceStack.contains(ns)) {
***************
*** 405,411 ****
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedString(String text) throws IOException {
int i;
! int size = text.length();
for (i = 0; i < size; i++) {
--- 411,417 ----
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedString(final String text) throws IOException {
int i;
! final int size = text.length();
for (i = 0; i < size; i++) {
***************
*** 436,442 ****
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedAttributeString(String text) throws IOException {
int i;
! int size = text.length();
for (i = 0; i < size; i++) {
switch (text.charAt(i)) {
--- 442,448 ----
* entity reference, suitable for XML attributes.
*/
! private void writeEscapedAttributeString(final String text) throws IOException {
int i;
! final int size = text.length();
for (i = 0; i < size; i++) {
switch (text.charAt(i)) {
Index: CanonicalizerWithComments.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/CanonicalizerWithComments.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CanonicalizerWithComments.java 11 Nov 2003 21:18:07 -0000 1.2
--- CanonicalizerWithComments.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 12,15 ****
--- 12,21 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 pelle
+ * EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
+ * Otherwise You will Finaliate.
+ * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
+ * This should hopefully make everything more stable (and secure).
+ *
* Revision 1.2 2003/11/11 21:18:07 pelle
* Further vital reshuffling.
***************
*** 34,38 ****
*
*/
! public class CanonicalizerWithComments extends Canonicalizer{
public CanonicalizerWithComments() {
super(XPATH_W_COMMENTS);
--- 40,44 ----
*
*/
! public final class CanonicalizerWithComments extends Canonicalizer{
public CanonicalizerWithComments() {
super(XPATH_W_COMMENTS);
Index: CanonicalizerWithoutSignature.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/c14/CanonicalizerWithoutSignature.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** CanonicalizerWithoutSignature.java 11 Nov 2003 21:18:07 -0000 1.2
--- CanonicalizerWithoutSignature.java 21 Nov 2003 04:44:30 -0000 1.3
***************
*** 14,17 ****
--- 14,23 ----
* $Id$
* $Log$
+ * Revision 1.3 2003/11/21 04:44:30 pelle
+ * EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
+ * Otherwise You will Finaliate.
+ * Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
+ * This should hopefully make everything more stable (and secure).
+ *
* Revision 1.2 2003/11/11 21:18:07 pelle
* Further vital reshuffling.
***************
*** 46,50 ****
*
*/
! public class CanonicalizerWithoutSignature extends Canonicalizer{
public CanonicalizerWithoutSignature() {
--- 52,56 ----
*
*/
! public final class CanonicalizerWithoutSignature extends Canonicalizer{
public CanonicalizerWithoutSignature() {
|