1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="Apache Forrest" name="Generator">
<meta name="Forrest-version" content="0.6">
<meta name="Forrest-skin-name" content="pelt">
<title>Frequently Asked Questions - Java</title>
<link type="text/css" href="../skin/basic.css" rel="stylesheet">
<link media="screen" type="text/css" href="../skin/screen.css" rel="stylesheet">
<link media="print" type="text/css" href="../skin/print.css" rel="stylesheet">
<link type="text/css" href="../skin/profile.css" rel="stylesheet">
<script src="../skin/getBlank.js" language="javascript" type="text/javascript"></script><script src="../skin/getMenu.js" language="javascript" type="text/javascript"></script><script src="../skin/fontsize.js" language="javascript" type="text/javascript"></script>
</head>
<body onload="init()">
<script type="text/javascript">ndeSetTextSize();</script>
<div id="top">
<!--+
|breadtrail
+-->
<div class="breadtrail">
<a href="http://www.apache.org/">apache</a> > <a href="http://xml.apache.org/">xml.apache</a><script src="../skin/breadcrumbs.js" language="JavaScript" type="text/javascript"></script>
</div>
<!--+
|header
+-->
<div class="header">
<!--+
|start group logo
+-->
<div class="grouplogo">
<a href="http:///xml.apache.org"><img class="logoImage" alt="Apache XML" src="../images/group-logo.gif"></a>
</div>
<!--+
|end group logo
+-->
<!--+
|start Project Logo
+-->
<div class="projectlogo">
<a href="http://xml.apache.org/security"><img class="logoImage" alt="Apache XML Security" src="../images/project-logo.gif"></a>
</div>
<!--+
|end Project Logo
+-->
<!--+
|start Search
+-->
<div class="searchbox">
<form action="http://www.google.com/search" method="get" class="roundtopsmall">
<input value="xml.apache.org/security" name="sitesearch" type="hidden"><input onFocus="getBlank (this, 'Search the site with google:');" value="Search the site with google:" size="25" name="q" id="query" type="text">
<input name="Search" value="Search" type="submit">
</form>
</div>
<!--+
|end search
+-->
<!--+
|start Tabs
+-->
<ul id="tabs">
<li>
<a class="base-not-selected" href="../index.html">Home</a>
</li>
<li class="current">
<a class="base-selected" href="../Java/index.html">Java</a>
</li>
<li>
<a class="base-not-selected" href="../c/index.html">C++</a>
</li>
</ul>
<!--+
|end Tabs
+-->
</div>
</div>
<div id="main">
<div id="publishedStrip">
<!--+
|start Subtabs
+-->
<div id="level2tabs"></div>
<!--+
|end Endtabs
+-->
<script type="text/javascript" language="JavaScript"><!--
document.write("Published: " + document.lastModified);
// --></script>
</div>
<!--+
|breadtrail
+-->
<div class="breadtrail">
</div>
<!--+
|start Menu, mainarea
+-->
<!--+
|start Menu
+-->
<div id="menu">
<div onclick="SwitchMenu('menu_selected_1.1', '../skin/')" id="menu_selected_1.1Title" class="menutitle" style="background-image: url('../skin/images/chapter_open.gif');">Java</div>
<div id="menu_selected_1.1" class="selectedmenuitemgroup" style="display: block;">
<div class="menuitem">
<a title="" href="../Java/index.html">Index</a>
</div>
<div class="menuitem">
<a title="" href="../Java/installation.html">Installation</a>
</div>
<div class="menuitem">
<a title="" href="../Java/examples.html">Examples</a>
</div>
<div class="menupage">
<div class="menupagetitle">FAQs</div>
</div>
<div class="menuitem">
<a title="" href="../Java/api.html">API Docs</a>
</div>
<div class="menuitem">
<a title="" href="../Java/interop.html">Interoperability</a>
</div>
<div class="menuitem">
<a title="" href="http://lsd.student.utwente.nl/gump/xml-security/xml-security.html">Gump results</a>
</div>
<div class="menuitem">
<a title="" href="../Java/resolver.html">Resolvermania</a>
</div>
</div>
<div id="credit"></div>
<div id="roundbottom">
<img style="display: none" class="corner" height="15" width="15" alt="" src="../skin/images/rc-b-l-15-1body-2menu-3menu.png"></div>
<!--+
|alternative credits
+-->
</div>
<!--+
|end Menu
+-->
<!--+
|start content
+-->
<div id="content">
<div id="skinconf-txtlink"></div>
<h1>Frequently Asked Questions - Java</h1>
<a name="N10008"></a><a name="Questions"></a>
<h2 class="h3">Questions</h2>
<div class="section">
<a name="N1000C"></a><a name="general_j"></a>
<h3 class="h4">1. Questions about Java</h3>
<a name="N10010"></a><a name="security_j"></a>
<h4 class="faq">1.1.
I have a Java-(security/cryptography) problem. Can you help me?
</h4>
<div align="right">
<a href="#security_j-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
Go to the <a class="external" href="http://forum.java.sun.com/">java forum</a> of Sun. You can
find forums where you can ask questions like "How do I generate
a keypair", etc.
</p>
</div>
<a name="N1001C"></a><a name="xml_j"></a>
<h4 class="faq">1.2.
I have a Java-XML problem.
</h4>
<div align="right">
<a href="#xml_j-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
Go to the <a class="external" href="http://forum.java.sun.com/">java forum</a> of Sun, section
Java Technology & XML and have a look at <a class="external" href="http://xml.apache.org/xerces2-j/index.html"> Apache Xerces</a>.
</p>
</div>
<a name="N1002C"></a><a name="specific_"></a>
<h3 class="h4">2. Questions about this package</h3>
<a name="N10030"></a><a name="crimson"></a>
<h4 class="faq">2.1.
I'm using Crimson, but it throws Exceptions. Why?
</h4>
<div align="right">
<a href="#crimson-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
Crimson is not supported at the moment. The main reason is that
Crimson did not support the
<span class="codefrag">org.w3c.dom.traversal.TreeWalker</span> interface in the
past. Additionally, it does not support the
<span class="codefrag">org.apache.xerces.dom.DocumentImpl.putIdentifier(String ID,
Element e)</span> functionality where Xerces allows us to enable ID
attributes during document generation.
</p>
<p>
Use <a class="external" href="http://xml.apache.org/xerces2-j/index.html">Apache Xerces</a>
instead of Crimson.
</p>
</div>
<a name="N10045"></a><a name="bouncy"></a>
<h4 class="faq">2.2.
What's up with the Bouncy Castle CSP? / Where is my CSP?
</h4>
<div align="right">
<a href="#bouncy-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
There is <em>no</em> JCE bundled together with this
distribution. This is because the Apache Project web site is hosted
in the US where some export restrictions apply to the cryptographic
primitives.
</p>
<p>
The nice guys from the <a class="external" href="http://www.bouncycastle.org/">Legion of Bouncy
Castle</a> where so helpful to supply their JCE in a simple JAR
package so that we can simply fetch it during the compilation process
and put it into the <span class="codefrag">libs/</span> directory. When you use the
ant makefile <span class="codefrag">build.xml</span> and simply say <span class="codefrag">ant
compile</span> or <span class="codefrag">ant get-jce</span>, <span class="codefrag">ant</span> tries
to fetch this JAR from the australian server. After that step, the
compilation works completely.
</p>
<p>
The ant make tools initiates an automated download of the
BouncyCastle JCE. The file is downloaded into the <span class="codefrag">libs/</span>
directory and a "bc-" is prepended to the filename. This is
done because we want the provider name (bc means BouncyCastle) being
visible in the JAR's filename.
</p>
<div class="frame note">
<div class="label">Note</div>
<div class="content">
The fact that we <em>use</em> Bouncy in this project does not mean
that you <em>must</em> use it, it's only the default. If you take a
look at the configuration
<span class="codefrag">src/org/apache/xml/security/resource/config.xml</span>, you'll
notice the sections which do integrate these alternative JCEs.
</div>
</div>
<p>
More information can be found in the <a href="../Java/installation.html">Installation</a> section.
</p>
</div>
<a name="N1007F"></a><a name="logging"></a>
<h4 class="faq">2.3.
How do I enable/turn off logging?
</h4>
<div align="right">
<a href="#logging-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
The logging is configured in the <span class="codefrag">config.xml</span> file which
either in the <span class="codefrag">xmlsec.jar</span> file or in the class path. This
is a little bit complicated as config.xml is used both for library
wide configurations like algorithms as well as for the user setting
about log4j. This will be changed someday ;-))
</p>
<p>OK, so it goes: In the
<a class="external" href="http://cvs.apache.org/viewcvs.cgi/xml-security/src/org/apache/xml/security/resource/config.xml?rev=HEAD&content-type=text/vnd.viewcvs-markup">
<span class="codefrag">xml-security/src/org/apache/xml/security/resource/config.xml</span>
</a> file, there is an element called
<span class="codefrag"><log4j:configuration></span>. This element contains the
XML style configuration information as defined in the
<a class="external" href="http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/xml/DOMConfigurator.html">
log4j DOMConfigurator class
</a>. You can find examples
<a class="external" href="http://cvs.apache.org/viewcvs.cgi/jakarta-log4j/tests/input/xml/">here</a>
</p>
</div>
<a name="N100A2"></a><a name="baseURI"></a>
<h4 class="faq">2.4.
What is the meaning of BaseURI?
</h4>
<div align="right">
<a href="#baseURI-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
When you work with URIs like
"<span class="codefrag">http://www.example.com/index.html</span>", it is
quite sure what you mean as this is an absolute URL, i.e. it is clear
which protocol ise used to fetch which file from which server. When
you use such a URL inside a signature, the software can automatically
figure out what you sign. But when you sign something in your local
file system or if you use a relative path like
"<span class="codefrag">../1.txt</span>", it's not possible to understand
this reference without some context. <em>This</em> context is the
<span class="codefrag">BaseURI</span>. For instance, if you sign
<span class="codefrag">URI="../1.txt"</span> and the
<span class="codefrag">BaseURI="file:///home/user/work/signature.xml"</span>,
it is clear that the file
<span class="codefrag">BaseURI="file:///home/user/1.txt"</span> is to be
signed. But when you create the signature, the file
<span class="codefrag">BaseURI="file:///home/user/work/signature.xml"</span>
does not yet exist; therefore, you have to supply the URL where you
intend to store the signature later (relative to the signed objects).
</p>
<p>
The String BaseURI is the systemID on which the Object will be stored
in the future. This is needed to resolve relative links in the
<span class="codefrag">Reference</span> elements which point to the filesystem or
something similar.
</p>
<p>
Example: Imagine that you want to create a signature to store it on a
web server as
<span class="codefrag">http://www.acme.com/signatures/sig1.xml</span>. So
<span class="codefrag">BaseURI="http://www.acme.com/sig1.xml"</span>. This
means that if you create a <span class="codefrag">Reference</span> with
<span class="codefrag">URI="./index.html"</span>, the library can easily use
it's HTTPResourceResolver to fetch
<span class="codefrag">http://www.acme.com/index.html</span> without that you have to
say <span class="codefrag">URI="http://www.acme.com/index.html"</span>.
</p>
</div>
<a name="N100E0"></a><a name="examples"></a>
<h4 class="faq">2.5.
How do I use the package to generate and verify a signature?
</h4>
<div align="right">
<a href="#examples-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
Checkout the samples in
<span class="codefrag">src_samples/org/apache/xml/security/samples/signature/</span>.
</p>
<div class="frame note">
<div class="label">Note</div>
<div class="content">
The samples divide into two groups: Samples that <em>create</em> and
samples that <em>verify</em> Signatures. Eventually, you should
adjust the verifying program to another filename if you get
<span class="codefrag">FileNotFoundException</span>s.
</div>
</div>
</div>
<a name="N100F7"></a><a name="jdk140"></a>
<h4 class="faq">2.6.
I'm using SUN JDK v1.4.0 or v1.4.1 and it get some exceptions. Any clues?
</h4>
<div align="right">
<a href="#jdk140-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
After SUN released the <a class="external" href="http://java.sun.com/j2se/1.4/index.html"> Java (TM) 2 Platform
Standard Edition v1.4.0 </a>, the xml-security package stopped
working. This is a
<a class="external" href="http://developer.java.sun.com/developer/bugParade/bugs/4615582.html">
known
</a>
problem: SUN packaged a beta of Xalan into the JDK1.4.0, but the
xml-security package requires a stable version of Xalan (v2.2.0 or
later). To fix the problem, you have to put the xalan.jar into a
special directory in your JDK:
<span class="codefrag">j2sdk1.4.0/jre/lib/endorsed/xalan.jar</span>. If you installed
an out-of-the-box JDK1.4 (e.g. on Windows 2000), the
"endorsed" directory does not exist: you'll have to create
it by hand.
</p>
<div class="frame warning">
<div class="label">Warning</div>
<div class="content">Putting this JAR to another location like lib/ext WILL NOT WORK. </div>
</div>
<p>
For more on that, you can also check the <a class="external" href="http://xml.apache.org/~edwingo/jaxp-faq.html#override">
Unofficial JAXP FAQ </a>.
</p>
</div>
<a name="N10114"></a><a name="nullptrexception"></a>
<h4 class="faq">2.7.
I get a NullPointerException, and I don't know what's wrong.
</h4>
<div align="right">
<a href="#nullptrexception-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
Often, this problem is caused by using DOM1 calls like
<span class="codefrag">createElement(), setAttribute(), createAttribute()</span>. These are
non-namespace-aware and will cause XPath and C14N errors.
Always use the DOM2 <span class="codefrag">create(Attribute|Element)NS(...)</span>
methods instead, even if you're creating an element without a namespace
(in that case, you can use null as a namespace).
</p>
<p>
The Xalan-J Team told us that DOM1 calls are deprecated and are not to
be used in code. xml-security has been reviewed and is DOM1 clean now.
The Xalan folks told us that if you create Elements or attributes
using DOM1 calls which are not namespace aware, they do not care about
any problem you have because of incorrect hehaviour of Xalan.
</p>
</div>
<a name="N10125"></a><a name="elementorder"></a>
<h4 class="faq">2.8.
I sign a document and when I try to verify using the same key, it fails
</h4>
<div align="right">
<a href="#elementorder-menu">^</a>
</div>
<div style="margin-left: 15px">
<p>
After you have created the XMLSignature object, before you sign the
document, you <em>must</em> embed the signature element in the owning
document (using a call to <span class="codefrag">XMLSignature.getElement()</span> to
retrieve the newly created Element node from the signature) before
calling the <span class="codefrag">XMLSignature.sign()</span> method,
</p>
<p>
During canonicalisation of the SignedInfo element, the library looks
at the parent and ancestor nodes of the Signature element to find
any namespaces that the SignedInfo node has inherited. Any that are
found are embedded in the canonical form of the SignedInfo. (This
is not true when Exclusive Canonicalisation is used, but it is still
good practice to insert the element node prior to the sign()
method being called).
</p>
<p>
If you have not embedded the signature node in the document, it will
not have any parent or ancestor nodes, so it will not inherit their
namespaces. If you then embed it in the document and call <span class="codefrag">
verify()</span>, the namespaces will be found and the canonical
form of SignedInfo will be different to that generated during
<span class="codefrag">sign()</span>.
</p>
</div>
</div>
</div>
<!--+
|end content
+-->
<div class="clearboth"> </div>
</div>
<div id="footer">
<!--+
|start bottomstrip
+-->
<div class="lastmodified">
<script type="text/javascript"><!--
document.write("Last Published: " + document.lastModified);
// --></script>
</div>
<div class="copyright">
Copyright © 2002-2005 The Apache Software Foundation.</div>
<!--+
|end bottomstrip
+-->
</div>
</body>
</html>
|