6159N/A * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 4571N/A * @bug 4635230 6283345 6303830 6824440 6867348 7094155 0N/A * @summary Basic unit tests for generating XML Signatures with JSR 105 0N/A * @author Sean Mullan 0N/A * Test that recreates merlin-xmldsig-twenty-three test vectors but with 0N/A * different keys and X.509 data. 661N/A// private final static String DIR = "."; 0N/A // get key & self-signed certificate from keystore 0N/A // create common objects 0N/A // create SignedInfo 0N/A // create XMLSignature 661N/A// StringWriter sw = new StringWriter(); 661N/A// dumpDocument(doc, sw); 661N/A// System.out.println(sw.toString()); 0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
6159N/A// dumpDocument(doc, new PrintWriter(System.out)); 4571N/A (
"Unmarshalled signature is not equal to generated signature");
4571N/A // add attribute with no namespace 2009N/A// dumpDocument(doc, new PrintWriter(System.out)); 2009N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A // create references 0N/A +
" ancestor-or-self::dsig:SignedInfo " +
"\n" 0N/A +
" count(ancestor-or-self::dsig:Reference | " +
"\n" 0N/A +
" here()/ancestor::dsig:Reference[1]) > " +
"\n" 0N/A +
" count(ancestor-or-self::dsig:Reference) " +
"\n" 0N/A +
" count(ancestor-or-self::node() | " +
"\n" 0N/A +
" id('notaries')) = " +
"\n" 0N/A +
" count(ancestor-or-self::node()) " +
"\n";
0N/A // create SignedInfo 0N/A "ancestor-or-self::dsig:X509Data",
0N/A // Manifest Reference 1 0N/A // Manifest Reference 2 0N/A // Manifest Reference 3 0N/A +
" exclude-result-prefixes='foo' \n" 0N/A +
" version='1.0'>\n" 0N/A +
" <xsl:output encoding='UTF-8' \n" 0N/A +
" method='xml' />\n" 0N/A +
" <xsl:template match='/'>\n" 0N/A +
" <title>Notaries</title>\n" 0N/A +
" <xsl:value-of select='@name' />\n" 0N/A +
" </xsl:for-each>\n" 0N/A +
" </xsl:template>\n" 0N/A +
"</xsl:stylesheet>\n";
0N/A // SignatureProperties 0N/A // create XMLSignature 0N/A// StringWriter sw = new StringWriter(); 0N/A// dumpDocument(envDoc, sw); 0N/A "merlin-xmldsig-twenty-three" +
0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
0N/A// trans.setOutputProperty(OutputKeys.INDENT, "yes"); 0N/A // create SignedInfo 0N/A // create XMLSignature 0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
0N/A // create SignedInfo 0N/A // create XMLSignature 0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
0N/A // create reference 1 0N/A (
"#xpointer(id('to-be-signed'))",
0N/A // create reference 2 0N/A (
"#xpointer(id('to-be-signed'))",
0N/A // create reference 3 0N/A (
"#xpointer(id('to-be-signed'))",
0N/A // create reference 4 0N/A (
"#xpointer(id('to-be-signed'))",
0N/A // create SignedInfo 0N/A // create XMLSignature 0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
0N/A // create reference 1 0N/A // create reference 2 0N/A // create SignedInfo 0N/A // create XMLSignature 0N/A (
"Unmarshalled signature is not equal to generated signature");
0N/A throw new Exception(
"Validation of generated signature failed");
0N/A "070662842167565771936588335128634396171789331656318483584455493822" +
0N/A "400811200853331373030669235424928346190274044631949560438023934623" +
0N/A "71310375123430985057160";
0N/A "013232376895198612407547930718267435757728527029623408872245156039" +
0N/A "757713029036368719146452186041204237350521785240337048752071462798" +
0N/A "273003935646236777459223";
0N/A "0857393771208094202104259627990318636601332086981";
0N/A "054216440574364751416096484883257051280474283943804743768346673007" +
0N/A "661082626139005426812890807137245973106730741193551360857959820973" +
0N/A "90670890367185141189796";
0N/A "0527140396812450214498055937934275626078768840117";
0N/A "010800185049102889923150759252557522305032794699952150943573164381" +
0N/A "936603255999071981574575044810461362008102247767482738822150129277" +
0N/A "490998033971789476107463";
0N/A "016116973584421969795445996229612671947635798429212816611707210835" +
0N/A "915586591340598683996088487065438751488342251960069575392056288063" +
0N/A "6800379454345804879553";
0N/A "909423744508062468450669519128736624058048856940468016843888594585" +
0N/A "322862378444314635412341974900625010364163960238734457710620107530" +
0N/A "573945081856371709138380902553309075505688814637544923038853658690" +
0N/A "857672483016239697038853418682988686871489963827000080098971762923" +
0N/A "833614557257607521";
0N/A "297021581096848810374110568017963075809477047466189822987258068867" +
0N/A "704855380407747867998863645890602646601140183818953428006646987710" +
0N/A "237008997971129772408397621801631622129297063463868593083106979716" +
0N/A "204903524890556839550490384015324575598723478554854070823335021842" +
0N/A "210112348400928769";
0N/A * This URIDereferencer returns locally cached copies of http content to 0N/A * avoid test failures due to network glitches, etc. 0N/A // fallback on builtin deref