|
From: Pelle B. <pe...@us...> - 2004-04-17 17:26:23
|
Update of /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9914/src/java/org/neuclear/xml/xmlsec Modified Files: HTMLSignature.java Log Message: Improved formatting of HTMLSignature Index: HTMLSignature.java =================================================================== RCS file: /cvsroot/neuclear/neuclear-xmlsig/src/java/org/neuclear/xml/xmlsec/HTMLSignature.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HTMLSignature.java 16 Apr 2004 23:54:03 -0000 1.1 --- HTMLSignature.java 17 Apr 2004 17:26:14 -0000 1.2 *************** *** 1,4 **** --- 1,24 ---- package org.neuclear.xml.xmlsec; + /* + * The NeuClear Project and it's libraries are + * (c) 2002-2004 Antilles Software Ventures SA + * For more information see: http://neuclear.org + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + import org.dom4j.Document; import org.dom4j.Element; *************** *** 37,64 **** Tidy tidy = new Tidy(); tidy.setXmlOut(true); ! org.w3c.dom.Document dom = tidy.parseDOM(is, System.out); DOMReader reader = new DOMReader(); Document doc = reader.read(dom); Element html = doc.getRootElement(); createHTMLBadge(html); ! si.getElement().addAttribute("id", "dsdigestvalue"); si.setEnvelopedReference(html); html.add(getElement()); sign(name, signer); ! sigval.addAttribute("id", "dssigvalue"); final Element ki = getElement().element("KeyInfo"); ! if (ki != null) ki.addAttribute("id", "dskeyinfo"); } private void createHTMLBadge(Element elem) { Element head = elem.element("head"); - Element css = head.addElement("link"); - css.addAttribute("rel", "stylesheet"); - css.addAttribute("href", "http://neuclear.org/sig.css"); - css.addAttribute("type", "text/css"); Element body = elem.element("body"); // body.addElement("hr"); Element title = body.addElement("p"); title.addAttribute("id", "dsigtitle"); title.setText("This page has been digitally signed."); body.addText("\n"); --- 57,83 ---- Tidy tidy = new Tidy(); tidy.setXmlOut(true); ! org.w3c.dom.Document dom = tidy.parseDOM(is, null); DOMReader reader = new DOMReader(); Document doc = reader.read(dom); Element html = doc.getRootElement(); createHTMLBadge(html); ! si.getElement().addAttribute("style", DIGESTSTYLE); si.setEnvelopedReference(html); html.add(getElement()); sign(name, signer); ! sigval.addAttribute("style", SIGSTYLE); ! // sigval.addAttribute("id", "dssigvalue"); final Element ki = getElement().element("KeyInfo"); ! if (ki != null) ki.addAttribute("style", KEYSTYLE); ! // if (ki != null) ki.addAttribute("id", "dskeyinfo"); } private void createHTMLBadge(Element elem) { Element head = elem.element("head"); Element body = elem.element("body"); // body.addElement("hr"); Element title = body.addElement("p"); title.addAttribute("id", "dsigtitle"); + title.addAttribute("style", TITLESTYLE); title.setText("This page has been digitally signed."); body.addText("\n"); *************** *** 85,95 **** Element html = doc.getRootElement(); createHTMLBadge(html); ! si.getElement().addAttribute("id", "dsdigestvalue"); si.setEnvelopedReference(html); html.add(getElement()); sign(signer); ! sigval.addAttribute("id", "dssigvalue"); final Element ki = getElement().element("KeyInfo"); ! if (ki != null) ki.addAttribute("id", "dskeyinfo"); } --- 104,117 ---- Element html = doc.getRootElement(); createHTMLBadge(html); ! // si.getElement().addAttribute("id", "dsdigestvalue"); ! si.getElement().addAttribute("style", DIGESTSTYLE); si.setEnvelopedReference(html); html.add(getElement()); sign(signer); ! sigval.addAttribute("style", SIGSTYLE); ! // sigval.addAttribute("id", "dssigvalue"); final Element ki = getElement().element("KeyInfo"); ! if (ki != null) ki.addAttribute("style", KEYSTYLE); ! // if (ki != null) ki.addAttribute("id", "dskeyinfo"); } *************** *** 99,103 **** * Uses the provided KeyPair to sign it. * ! * @param kp * @param elem * @throws XMLSecurityException --- 121,125 ---- * Uses the provided KeyPair to sign it. * ! * @param kp * @param elem * @throws XMLSecurityException *************** *** 118,120 **** --- 140,149 ---- } + + private static final String TITLESTYLE = "background:#00B; font-family:sans-serif; font-size: small;color:white"; + private static final String SIGSTYLE = "background:#EEF; font-family:monospace; font-size: xx-small; color:#004;display:block"; + private static final String KEYSTYLE = "display:none"; + // private static final String DIGESTSTYLE = "display:none"; + // private static final String KEYSTYLE = "background:#EFE; font-family:monospace; font-size: xx-small; color:#040;display:block;white-space:pre"; + private static final String DIGESTSTYLE = "background:#FEE; font-family:monospace; font-size: xx-small; color:#400;display:block"; } |