Modified: 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/CryptoUtil.html
==============================================================================
--- 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/CryptoUtil.html
 (original)
+++ 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/CryptoUtil.html
 Tue May 21 03:58:58 2019
@@ -1,231 +1,236 @@
-<HTML>
-<BODY BGCOLOR="white">
-<PRE>
-<FONT color="green">001</FONT>    package org.apache.fulcrum.jce.crypto;<a 
name="line.1"></a>
-<FONT color="green">002</FONT>    <a name="line.2"></a>
-<FONT color="green">003</FONT>    /*<a name="line.3"></a>
-<FONT color="green">004</FONT>     * Licensed to the Apache Software 
Foundation (ASF) under one<a name="line.4"></a>
-<FONT color="green">005</FONT>     * or more contributor license agreements.  
See the NOTICE file<a name="line.5"></a>
-<FONT color="green">006</FONT>     * distributed with this work for additional 
information<a name="line.6"></a>
-<FONT color="green">007</FONT>     * regarding copyright ownership.  The ASF 
licenses this file<a name="line.7"></a>
-<FONT color="green">008</FONT>     * to you under the Apache License, Version 
2.0 (the<a name="line.8"></a>
-<FONT color="green">009</FONT>     * "License"); you may not use this file 
except in compliance<a name="line.9"></a>
-<FONT color="green">010</FONT>     * with the License.  You may obtain a copy 
of the License at<a name="line.10"></a>
-<FONT color="green">011</FONT>     *<a name="line.11"></a>
-<FONT color="green">012</FONT>     *   
http://www.apache.org/licenses/LICENSE-2.0<a name="line.12"></a>
-<FONT color="green">013</FONT>     *<a name="line.13"></a>
-<FONT color="green">014</FONT>     * Unless required by applicable law or 
agreed to in writing,<a name="line.14"></a>
-<FONT color="green">015</FONT>     * software distributed under the License is 
distributed on an<a name="line.15"></a>
-<FONT color="green">016</FONT>     * "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY<a name="line.16"></a>
-<FONT color="green">017</FONT>     * KIND, either express or implied.  See the 
License for the<a name="line.17"></a>
-<FONT color="green">018</FONT>     * specific language governing permissions 
and limitations<a name="line.18"></a>
-<FONT color="green">019</FONT>     * under the License.<a name="line.19"></a>
-<FONT color="green">020</FONT>     */<a name="line.20"></a>
-<FONT color="green">021</FONT>    <a name="line.21"></a>
-<FONT color="green">022</FONT>    <a name="line.22"></a>
-<FONT color="green">023</FONT>    import java.io.ByteArrayOutputStream;<a 
name="line.23"></a>
-<FONT color="green">024</FONT>    import java.io.IOException;<a 
name="line.24"></a>
-<FONT color="green">025</FONT>    import java.io.InputStream;<a 
name="line.25"></a>
-<FONT color="green">026</FONT>    import java.io.OutputStream;<a 
name="line.26"></a>
-<FONT color="green">027</FONT>    import 
java.security.GeneralSecurityException;<a name="line.27"></a>
-<FONT color="green">028</FONT>    <a name="line.28"></a>
-<FONT color="green">029</FONT>    /**<a name="line.29"></a>
-<FONT color="green">030</FONT>     * Helper class to provde generic functions 
to work with CryptoStreams.<a name="line.30"></a>
-<FONT color="green">031</FONT>     *<a name="line.31"></a>
-<FONT color="green">032</FONT>     * The code uses parts from Markus Hahn's 
Blowfish library found at<a name="line.32"></a>
-<FONT color="green">033</FONT>     * http://blowfishj.sourceforge.net/<a 
name="line.33"></a>
-<FONT color="green">034</FONT>     *<a name="line.34"></a>
-<FONT color="green">035</FONT>     * @author &lt;a 
href="mailto:[email protected]"&gt;Siegfried Goeschl &lt;/a&gt;<a 
name="line.35"></a>
-<FONT color="green">036</FONT>     * @author &lt;a 
href="mailto:[email protected]"&gt;Markus Hahn&lt;/a&gt;<a 
name="line.36"></a>
-<FONT color="green">037</FONT>     */<a name="line.37"></a>
-<FONT color="green">038</FONT>    <a name="line.38"></a>
-<FONT color="green">039</FONT>    public final class CryptoUtil<a 
name="line.39"></a>
-<FONT color="green">040</FONT>    {<a name="line.40"></a>
-<FONT color="green">041</FONT>        /**<a name="line.41"></a>
-<FONT color="green">042</FONT>         * Copies from a source to a target 
object using encryption<a name="line.42"></a>
-<FONT color="green">043</FONT>         *<a name="line.43"></a>
-<FONT color="green">044</FONT>         * @param source the source object<a 
name="line.44"></a>
-<FONT color="green">045</FONT>         * @param target the target object<a 
name="line.45"></a>
-<FONT color="green">046</FONT>         * @param password the password to use 
for encryption<a name="line.46"></a>
-<FONT color="green">047</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.47"></a>
-<FONT color="green">048</FONT>         * @throws IOException accessing the 
souce failed<a name="line.48"></a>
-<FONT color="green">049</FONT>         *<a name="line.49"></a>
-<FONT color="green">050</FONT>         */<a name="line.50"></a>
-<FONT color="green">051</FONT>        public static void encrypt( Object 
source, Object target, char[] password )<a name="line.51"></a>
-<FONT color="green">052</FONT>            throws GeneralSecurityException, 
IOException<a name="line.52"></a>
-<FONT color="green">053</FONT>        {<a name="line.53"></a>
-<FONT color="green">054</FONT>            CryptoUtil.encrypt(<a 
name="line.54"></a>
-<FONT color="green">055</FONT>                
CryptoUtil.getCryptoStreamFactory(),<a name="line.55"></a>
-<FONT color="green">056</FONT>                source,<a name="line.56"></a>
-<FONT color="green">057</FONT>                target,<a name="line.57"></a>
-<FONT color="green">058</FONT>                password<a name="line.58"></a>
-<FONT color="green">059</FONT>                );<a name="line.59"></a>
-<FONT color="green">060</FONT>        }<a name="line.60"></a>
-<FONT color="green">061</FONT>    <a name="line.61"></a>
-<FONT color="green">062</FONT>        /**<a name="line.62"></a>
-<FONT color="green">063</FONT>         * Copies from a source to a target 
object using encryption and a<a name="line.63"></a>
-<FONT color="green">064</FONT>         * caller supplied 
CryptoStreamFactory.<a name="line.64"></a>
-<FONT color="green">065</FONT>         *<a name="line.65"></a>
-<FONT color="green">066</FONT>         * @param factory the factory to create 
the crypto streams<a name="line.66"></a>
-<FONT color="green">067</FONT>         * @param source the source object<a 
name="line.67"></a>
-<FONT color="green">068</FONT>         * @param target the target object<a 
name="line.68"></a>
-<FONT color="green">069</FONT>         * @param password the password to use 
for encryption<a name="line.69"></a>
-<FONT color="green">070</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.70"></a>
-<FONT color="green">071</FONT>         * @throws IOException accessing the 
souce failed<a name="line.71"></a>
-<FONT color="green">072</FONT>         */<a name="line.72"></a>
-<FONT color="green">073</FONT>        public static void encrypt(<a 
name="line.73"></a>
-<FONT color="green">074</FONT>            CryptoStreamFactory factory, Object 
source, Object target, char[] password )<a name="line.74"></a>
-<FONT color="green">075</FONT>            throws GeneralSecurityException, 
IOException<a name="line.75"></a>
-<FONT color="green">076</FONT>        {<a name="line.76"></a>
-<FONT color="green">077</FONT>            InputStream is = 
StreamUtil.createInputStream( source );<a name="line.77"></a>
-<FONT color="green">078</FONT>            OutputStream os = 
StreamUtil.createOutputStream( target );<a name="line.78"></a>
-<FONT color="green">079</FONT>            OutputStream eos = 
factory.getOutputStream( os, password );<a name="line.79"></a>
-<FONT color="green">080</FONT>            StreamUtil.copy( is, eos );<a 
name="line.80"></a>
-<FONT color="green">081</FONT>        }<a name="line.81"></a>
-<FONT color="green">082</FONT>    <a name="line.82"></a>
-<FONT color="green">083</FONT>        /**<a name="line.83"></a>
-<FONT color="green">084</FONT>         * Copies from a source to a target 
object using decryption.<a name="line.84"></a>
-<FONT color="green">085</FONT>         *<a name="line.85"></a>
-<FONT color="green">086</FONT>         * @param source the source object<a 
name="line.86"></a>
-<FONT color="green">087</FONT>         * @param target the target object<a 
name="line.87"></a>
-<FONT color="green">088</FONT>         * @param password the password to use 
for decryption<a name="line.88"></a>
-<FONT color="green">089</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.89"></a>
-<FONT color="green">090</FONT>         * @throws IOException accessing the 
souce failed<a name="line.90"></a>
-<FONT color="green">091</FONT>         */<a name="line.91"></a>
-<FONT color="green">092</FONT>        public static void decrypt( Object 
source, Object target, char[] password )<a name="line.92"></a>
-<FONT color="green">093</FONT>            throws GeneralSecurityException, 
IOException<a name="line.93"></a>
-<FONT color="green">094</FONT>        {<a name="line.94"></a>
-<FONT color="green">095</FONT>            CryptoUtil.decrypt(<a 
name="line.95"></a>
-<FONT color="green">096</FONT>                
CryptoUtil.getCryptoStreamFactory(),<a name="line.96"></a>
-<FONT color="green">097</FONT>                source,<a name="line.97"></a>
-<FONT color="green">098</FONT>                target,<a name="line.98"></a>
-<FONT color="green">099</FONT>                password<a name="line.99"></a>
-<FONT color="green">100</FONT>                );<a name="line.100"></a>
-<FONT color="green">101</FONT>        }<a name="line.101"></a>
-<FONT color="green">102</FONT>    <a name="line.102"></a>
-<FONT color="green">103</FONT>        /**<a name="line.103"></a>
-<FONT color="green">104</FONT>         * Copies from a source to a target 
object using decryption and a<a name="line.104"></a>
-<FONT color="green">105</FONT>         * caller-suppier CryptoStreamFactory.<a 
name="line.105"></a>
-<FONT color="green">106</FONT>         *<a name="line.106"></a>
-<FONT color="green">107</FONT>         * @param factory the factory to create 
the crypto streams<a name="line.107"></a>
-<FONT color="green">108</FONT>         * @param source the source object<a 
name="line.108"></a>
-<FONT color="green">109</FONT>         * @param target the target object<a 
name="line.109"></a>
-<FONT color="green">110</FONT>         * @param password the password to use 
for decryption<a name="line.110"></a>
-<FONT color="green">111</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.111"></a>
-<FONT color="green">112</FONT>         * @throws IOException accessing the 
souce failed<a name="line.112"></a>
-<FONT color="green">113</FONT>         */<a name="line.113"></a>
-<FONT color="green">114</FONT>        public static void decrypt(<a 
name="line.114"></a>
-<FONT color="green">115</FONT>            CryptoStreamFactory factory, Object 
source, Object target, char[] password )<a name="line.115"></a>
-<FONT color="green">116</FONT>            throws GeneralSecurityException, 
IOException<a name="line.116"></a>
-<FONT color="green">117</FONT>        {<a name="line.117"></a>
-<FONT color="green">118</FONT>            InputStream is = 
StreamUtil.createInputStream( source );<a name="line.118"></a>
-<FONT color="green">119</FONT>            OutputStream os = 
StreamUtil.createOutputStream( target );<a name="line.119"></a>
-<FONT color="green">120</FONT>            InputStream dis = 
factory.getInputStream( is, password );<a name="line.120"></a>
-<FONT color="green">121</FONT>            StreamUtil.copy( dis, os );<a 
name="line.121"></a>
-<FONT color="green">122</FONT>        }<a name="line.122"></a>
-<FONT color="green">123</FONT>    <a name="line.123"></a>
-<FONT color="green">124</FONT>        /**<a name="line.124"></a>
-<FONT color="green">125</FONT>         * Encrypts a string into a hex 
string.<a name="line.125"></a>
-<FONT color="green">126</FONT>         *<a name="line.126"></a>
-<FONT color="green">127</FONT>         * @param plainText the plain text to be 
encrypted<a name="line.127"></a>
-<FONT color="green">128</FONT>         * @param password the password for 
encryption<a name="line.128"></a>
-<FONT color="green">129</FONT>         * @return the encrypted string<a 
name="line.129"></a>
-<FONT color="green">130</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.130"></a>
-<FONT color="green">131</FONT>         * @throws IOException accessing the 
souce failed<a name="line.131"></a>
-<FONT color="green">132</FONT>         */<a name="line.132"></a>
-<FONT color="green">133</FONT>        public static String encryptString( 
String plainText, char[] password )<a name="line.133"></a>
-<FONT color="green">134</FONT>            throws GeneralSecurityException, 
IOException<a name="line.134"></a>
-<FONT color="green">135</FONT>        {<a name="line.135"></a>
-<FONT color="green">136</FONT>            return CryptoUtil.encryptString(<a 
name="line.136"></a>
-<FONT color="green">137</FONT>                
CryptoUtil.getCryptoStreamFactory(),<a name="line.137"></a>
-<FONT color="green">138</FONT>                plainText,<a name="line.138"></a>
-<FONT color="green">139</FONT>                password<a name="line.139"></a>
-<FONT color="green">140</FONT>                );<a name="line.140"></a>
-<FONT color="green">141</FONT>        }<a name="line.141"></a>
-<FONT color="green">142</FONT>    <a name="line.142"></a>
-<FONT color="green">143</FONT>        /**<a name="line.143"></a>
-<FONT color="green">144</FONT>         * Encrypts a string into a hex 
string.<a name="line.144"></a>
-<FONT color="green">145</FONT>         *<a name="line.145"></a>
-<FONT color="green">146</FONT>         * @param factory the factory to create 
the crypto streams<a name="line.146"></a>
-<FONT color="green">147</FONT>         * @param plainText the plain text to be 
encrypted<a name="line.147"></a>
-<FONT color="green">148</FONT>         * @param password the password for 
encryption<a name="line.148"></a>
-<FONT color="green">149</FONT>         * @return the encrypted string<a 
name="line.149"></a>
-<FONT color="green">150</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.150"></a>
-<FONT color="green">151</FONT>         * @throws IOException accessing the 
souce failed<a name="line.151"></a>
-<FONT color="green">152</FONT>         */<a name="line.152"></a>
-<FONT color="green">153</FONT>        public static String encryptString(<a 
name="line.153"></a>
-<FONT color="green">154</FONT>            CryptoStreamFactory factory, String 
plainText, char[] password )<a name="line.154"></a>
-<FONT color="green">155</FONT>            throws GeneralSecurityException, 
IOException<a name="line.155"></a>
-<FONT color="green">156</FONT>        {<a name="line.156"></a>
-<FONT color="green">157</FONT>            ByteArrayOutputStream bais = new 
ByteArrayOutputStream();<a name="line.157"></a>
-<FONT color="green">158</FONT>            CryptoUtil.encrypt( factory, 
plainText, bais, password );<a name="line.158"></a>
-<FONT color="green">159</FONT>            return HexConverter.toString( 
bais.toByteArray() );<a name="line.159"></a>
-<FONT color="green">160</FONT>        }<a name="line.160"></a>
-<FONT color="green">161</FONT>    <a name="line.161"></a>
-<FONT color="green">162</FONT>        /**<a name="line.162"></a>
-<FONT color="green">163</FONT>         * Decrypts an encrypted string into the 
plain text. The encrypted<a name="line.163"></a>
-<FONT color="green">164</FONT>         * string must be a hex string created 
by encryptString.<a name="line.164"></a>
-<FONT color="green">165</FONT>         *<a name="line.165"></a>
-<FONT color="green">166</FONT>         * @param cipherText the encrypted text 
to be decrypted<a name="line.166"></a>
-<FONT color="green">167</FONT>         * @param password the password for 
decryption<a name="line.167"></a>
-<FONT color="green">168</FONT>         * @return the decrypted string<a 
name="line.168"></a>
-<FONT color="green">169</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.169"></a>
-<FONT color="green">170</FONT>         * @throws IOException accessing the 
souce failed<a name="line.170"></a>
-<FONT color="green">171</FONT>         */<a name="line.171"></a>
-<FONT color="green">172</FONT>        public static String decryptString( 
String cipherText, char[] password )<a name="line.172"></a>
-<FONT color="green">173</FONT>            throws GeneralSecurityException, 
IOException<a name="line.173"></a>
-<FONT color="green">174</FONT>        {<a name="line.174"></a>
-<FONT color="green">175</FONT>            return CryptoUtil.decryptString(<a 
name="line.175"></a>
-<FONT color="green">176</FONT>                
CryptoUtil.getCryptoStreamFactory(),<a name="line.176"></a>
-<FONT color="green">177</FONT>                cipherText,<a 
name="line.177"></a>
-<FONT color="green">178</FONT>                password<a name="line.178"></a>
-<FONT color="green">179</FONT>                );<a name="line.179"></a>
-<FONT color="green">180</FONT>        }<a name="line.180"></a>
-<FONT color="green">181</FONT>    <a name="line.181"></a>
-<FONT color="green">182</FONT>        /**<a name="line.182"></a>
-<FONT color="green">183</FONT>         * Decrypts an encrypted string into the 
plain text. The encrypted<a name="line.183"></a>
-<FONT color="green">184</FONT>         * string must be a hex string created 
by encryptString.<a name="line.184"></a>
-<FONT color="green">185</FONT>         *<a name="line.185"></a>
-<FONT color="green">186</FONT>         * @param factory the factory to create 
the crypto streams<a name="line.186"></a>
-<FONT color="green">187</FONT>         * @param cipherText the encrypted text 
to be decrypted<a name="line.187"></a>
-<FONT color="green">188</FONT>         * @param password the password for 
decryption<a name="line.188"></a>
-<FONT color="green">189</FONT>         * @return the decrypted string<a 
name="line.189"></a>
-<FONT color="green">190</FONT>         * @throws GeneralSecurityException 
accessing JCE failed<a name="line.190"></a>
-<FONT color="green">191</FONT>         * @throws IOException accessing the 
souce failed<a name="line.191"></a>
-<FONT color="green">192</FONT>         */<a name="line.192"></a>
-<FONT color="green">193</FONT>        public static String decryptString(<a 
name="line.193"></a>
-<FONT color="green">194</FONT>            CryptoStreamFactory factory, String 
cipherText, char[] password )<a name="line.194"></a>
-<FONT color="green">195</FONT>            throws GeneralSecurityException, 
IOException<a name="line.195"></a>
-<FONT color="green">196</FONT>        {<a name="line.196"></a>
-<FONT color="green">197</FONT>            byte[] buffer = 
HexConverter.toBytes( cipherText );<a name="line.197"></a>
-<FONT color="green">198</FONT>            ByteArrayOutputStream bais = new 
ByteArrayOutputStream();<a name="line.198"></a>
-<FONT color="green">199</FONT>            CryptoUtil.decrypt( factory, buffer, 
bais, password );<a name="line.199"></a>
-<FONT color="green">200</FONT>            return new String( 
bais.toByteArray(), "utf-8" );<a name="line.200"></a>
-<FONT color="green">201</FONT>        }<a name="line.201"></a>
-<FONT color="green">202</FONT>    <a name="line.202"></a>
-<FONT color="green">203</FONT>        /**<a name="line.203"></a>
-<FONT color="green">204</FONT>         * Pumps the input stream to the output 
stream.<a name="line.204"></a>
-<FONT color="green">205</FONT>         *<a name="line.205"></a>
-<FONT color="green">206</FONT>         * @param is the source input stream<a 
name="line.206"></a>
-<FONT color="green">207</FONT>         * @param os the target output stream<a 
name="line.207"></a>
-<FONT color="green">208</FONT>         * @return the number of bytes copied<a 
name="line.208"></a>
-<FONT color="green">209</FONT>         * @throws IOException the copying 
failed<a name="line.209"></a>
-<FONT color="green">210</FONT>         * @deprecated use StreamUtil instead<a 
name="line.210"></a>
-<FONT color="green">211</FONT>         */<a name="line.211"></a>
-<FONT color="green">212</FONT>        public static long copy( InputStream is, 
OutputStream os )<a name="line.212"></a>
-<FONT color="green">213</FONT>            throws IOException<a 
name="line.213"></a>
-<FONT color="green">214</FONT>        {<a name="line.214"></a>
-<FONT color="green">215</FONT>            return StreamUtil.copy(is, os);<a 
name="line.215"></a>
-<FONT color="green">216</FONT>        }<a name="line.216"></a>
-<FONT color="green">217</FONT>    <a name="line.217"></a>
-<FONT color="green">218</FONT>        /**<a name="line.218"></a>
-<FONT color="green">219</FONT>         * @return the CryptoStreamFactory to be 
used<a name="line.219"></a>
-<FONT color="green">220</FONT>         */<a name="line.220"></a>
-<FONT color="green">221</FONT>        public static CryptoStreamFactory 
getCryptoStreamFactory()<a name="line.221"></a>
-<FONT color="green">222</FONT>        {<a name="line.222"></a>
-<FONT color="green">223</FONT>            return 
CryptoStreamFactoryImpl.getInstance();<a name="line.223"></a>
-<FONT color="green">224</FONT>        }<a name="line.224"></a>
-<FONT color="green">225</FONT>    }<a name="line.225"></a>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" 
title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>package 
org.apache.fulcrum.jce.crypto;<a name="line.1"></a>
+<span class="sourceLineNo">002</span><a name="line.2"></a>
+<span class="sourceLineNo">003</span>/*<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * Licensed to the Apache Software 
Foundation (ASF) under one<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * or more contributor license 
agreements.  See the NOTICE file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * distributed with this work for 
additional information<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * regarding copyright ownership.  The 
ASF licenses this file<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * to you under the Apache License, 
Version 2.0 (the<a name="line.8"></a>
+<span class="sourceLineNo">009</span> * "License"); you may not use this file 
except in compliance<a name="line.9"></a>
+<span class="sourceLineNo">010</span> * with the License.  You may obtain a 
copy of the License at<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> *   
http://www.apache.org/licenses/LICENSE-2.0<a name="line.12"></a>
+<span class="sourceLineNo">013</span> *<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * Unless required by applicable law or 
agreed to in writing,<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * software distributed under the License 
is distributed on an<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY<a name="line.16"></a>
+<span class="sourceLineNo">017</span> * KIND, either express or implied.  See 
the License for the<a name="line.17"></a>
+<span class="sourceLineNo">018</span> * specific language governing 
permissions and limitations<a name="line.18"></a>
+<span class="sourceLineNo">019</span> * under the License.<a 
name="line.19"></a>
+<span class="sourceLineNo">020</span> */<a name="line.20"></a>
+<span class="sourceLineNo">021</span><a name="line.21"></a>
+<span class="sourceLineNo">022</span><a name="line.22"></a>
+<span class="sourceLineNo">023</span>import java.io.ByteArrayOutputStream;<a 
name="line.23"></a>
+<span class="sourceLineNo">024</span>import java.io.IOException;<a 
name="line.24"></a>
+<span class="sourceLineNo">025</span>import java.io.InputStream;<a 
name="line.25"></a>
+<span class="sourceLineNo">026</span>import java.io.OutputStream;<a 
name="line.26"></a>
+<span class="sourceLineNo">027</span>import 
java.security.GeneralSecurityException;<a name="line.27"></a>
+<span class="sourceLineNo">028</span><a name="line.28"></a>
+<span class="sourceLineNo">029</span>/**<a name="line.29"></a>
+<span class="sourceLineNo">030</span> * Helper class to provde generic 
functions to work with CryptoStreams.<a name="line.30"></a>
+<span class="sourceLineNo">031</span> *<a name="line.31"></a>
+<span class="sourceLineNo">032</span> * The code uses parts from Markus Hahn's 
Blowfish library found at<a name="line.32"></a>
+<span class="sourceLineNo">033</span> * http://blowfishj.sourceforge.net/<a 
name="line.33"></a>
+<span class="sourceLineNo">034</span> *<a name="line.34"></a>
+<span class="sourceLineNo">035</span> * @author &lt;a 
href="mailto:[email protected]"&gt;Siegfried Goeschl &lt;/a&gt;<a 
name="line.35"></a>
+<span class="sourceLineNo">036</span> * @author &lt;a 
href="mailto:[email protected]"&gt;Markus Hahn&lt;/a&gt;<a 
name="line.36"></a>
+<span class="sourceLineNo">037</span> */<a name="line.37"></a>
+<span class="sourceLineNo">038</span><a name="line.38"></a>
+<span class="sourceLineNo">039</span>public final class CryptoUtil<a 
name="line.39"></a>
+<span class="sourceLineNo">040</span>{<a name="line.40"></a>
+<span class="sourceLineNo">041</span>    /**<a name="line.41"></a>
+<span class="sourceLineNo">042</span>     * Copies from a source to a target 
object using encryption<a name="line.42"></a>
+<span class="sourceLineNo">043</span>     *<a name="line.43"></a>
+<span class="sourceLineNo">044</span>     * @param source the source object<a 
name="line.44"></a>
+<span class="sourceLineNo">045</span>     * @param target the target object<a 
name="line.45"></a>
+<span class="sourceLineNo">046</span>     * @param password the password to 
use for encryption<a name="line.46"></a>
+<span class="sourceLineNo">047</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.47"></a>
+<span class="sourceLineNo">048</span>     * @throws IOException accessing the 
souce failed<a name="line.48"></a>
+<span class="sourceLineNo">049</span>     *<a name="line.49"></a>
+<span class="sourceLineNo">050</span>     */<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    public static void encrypt( Object 
source, Object target, char[] password )<a name="line.51"></a>
+<span class="sourceLineNo">052</span>        throws GeneralSecurityException, 
IOException<a name="line.52"></a>
+<span class="sourceLineNo">053</span>    {<a name="line.53"></a>
+<span class="sourceLineNo">054</span>        CryptoUtil.encrypt(<a 
name="line.54"></a>
+<span class="sourceLineNo">055</span>            
CryptoUtil.getCryptoStreamFactory(),<a name="line.55"></a>
+<span class="sourceLineNo">056</span>            source,<a name="line.56"></a>
+<span class="sourceLineNo">057</span>            target,<a name="line.57"></a>
+<span class="sourceLineNo">058</span>            password<a name="line.58"></a>
+<span class="sourceLineNo">059</span>            );<a name="line.59"></a>
+<span class="sourceLineNo">060</span>    }<a name="line.60"></a>
+<span class="sourceLineNo">061</span><a name="line.61"></a>
+<span class="sourceLineNo">062</span>    /**<a name="line.62"></a>
+<span class="sourceLineNo">063</span>     * Copies from a source to a target 
object using encryption and a<a name="line.63"></a>
+<span class="sourceLineNo">064</span>     * caller supplied 
CryptoStreamFactory.<a name="line.64"></a>
+<span class="sourceLineNo">065</span>     *<a name="line.65"></a>
+<span class="sourceLineNo">066</span>     * @param factory the factory to 
create the crypto streams<a name="line.66"></a>
+<span class="sourceLineNo">067</span>     * @param source the source object<a 
name="line.67"></a>
+<span class="sourceLineNo">068</span>     * @param target the target object<a 
name="line.68"></a>
+<span class="sourceLineNo">069</span>     * @param password the password to 
use for encryption<a name="line.69"></a>
+<span class="sourceLineNo">070</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.70"></a>
+<span class="sourceLineNo">071</span>     * @throws IOException accessing the 
souce failed<a name="line.71"></a>
+<span class="sourceLineNo">072</span>     */<a name="line.72"></a>
+<span class="sourceLineNo">073</span>    public static void encrypt(<a 
name="line.73"></a>
+<span class="sourceLineNo">074</span>        CryptoStreamFactory factory, 
Object source, Object target, char[] password )<a name="line.74"></a>
+<span class="sourceLineNo">075</span>        throws GeneralSecurityException, 
IOException<a name="line.75"></a>
+<span class="sourceLineNo">076</span>    {<a name="line.76"></a>
+<span class="sourceLineNo">077</span>        InputStream is = 
StreamUtil.createInputStream( source );<a name="line.77"></a>
+<span class="sourceLineNo">078</span>        OutputStream os = 
StreamUtil.createOutputStream( target );<a name="line.78"></a>
+<span class="sourceLineNo">079</span>        OutputStream eos = 
factory.getOutputStream( os, password );<a name="line.79"></a>
+<span class="sourceLineNo">080</span>        StreamUtil.copy( is, eos );<a 
name="line.80"></a>
+<span class="sourceLineNo">081</span>    }<a name="line.81"></a>
+<span class="sourceLineNo">082</span><a name="line.82"></a>
+<span class="sourceLineNo">083</span>    /**<a name="line.83"></a>
+<span class="sourceLineNo">084</span>     * Copies from a source to a target 
object using decryption.<a name="line.84"></a>
+<span class="sourceLineNo">085</span>     *<a name="line.85"></a>
+<span class="sourceLineNo">086</span>     * @param source the source object<a 
name="line.86"></a>
+<span class="sourceLineNo">087</span>     * @param target the target object<a 
name="line.87"></a>
+<span class="sourceLineNo">088</span>     * @param password the password to 
use for decryption<a name="line.88"></a>
+<span class="sourceLineNo">089</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.89"></a>
+<span class="sourceLineNo">090</span>     * @throws IOException accessing the 
souce failed<a name="line.90"></a>
+<span class="sourceLineNo">091</span>     */<a name="line.91"></a>
+<span class="sourceLineNo">092</span>    public static void decrypt( Object 
source, Object target, char[] password )<a name="line.92"></a>
+<span class="sourceLineNo">093</span>        throws GeneralSecurityException, 
IOException<a name="line.93"></a>
+<span class="sourceLineNo">094</span>    {<a name="line.94"></a>
+<span class="sourceLineNo">095</span>        CryptoUtil.decrypt(<a 
name="line.95"></a>
+<span class="sourceLineNo">096</span>            
CryptoUtil.getCryptoStreamFactory(),<a name="line.96"></a>
+<span class="sourceLineNo">097</span>            source,<a name="line.97"></a>
+<span class="sourceLineNo">098</span>            target,<a name="line.98"></a>
+<span class="sourceLineNo">099</span>            password<a name="line.99"></a>
+<span class="sourceLineNo">100</span>            );<a name="line.100"></a>
+<span class="sourceLineNo">101</span>    }<a name="line.101"></a>
+<span class="sourceLineNo">102</span><a name="line.102"></a>
+<span class="sourceLineNo">103</span>    /**<a name="line.103"></a>
+<span class="sourceLineNo">104</span>     * Copies from a source to a target 
object using decryption and a<a name="line.104"></a>
+<span class="sourceLineNo">105</span>     * caller-suppier 
CryptoStreamFactory.<a name="line.105"></a>
+<span class="sourceLineNo">106</span>     *<a name="line.106"></a>
+<span class="sourceLineNo">107</span>     * @param factory the factory to 
create the crypto streams<a name="line.107"></a>
+<span class="sourceLineNo">108</span>     * @param source the source object<a 
name="line.108"></a>
+<span class="sourceLineNo">109</span>     * @param target the target object<a 
name="line.109"></a>
+<span class="sourceLineNo">110</span>     * @param password the password to 
use for decryption<a name="line.110"></a>
+<span class="sourceLineNo">111</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.111"></a>
+<span class="sourceLineNo">112</span>     * @throws IOException accessing the 
souce failed<a name="line.112"></a>
+<span class="sourceLineNo">113</span>     */<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    public static void decrypt(<a 
name="line.114"></a>
+<span class="sourceLineNo">115</span>        CryptoStreamFactory factory, 
Object source, Object target, char[] password )<a name="line.115"></a>
+<span class="sourceLineNo">116</span>        throws GeneralSecurityException, 
IOException<a name="line.116"></a>
+<span class="sourceLineNo">117</span>    {<a name="line.117"></a>
+<span class="sourceLineNo">118</span>        InputStream is = 
StreamUtil.createInputStream( source );<a name="line.118"></a>
+<span class="sourceLineNo">119</span>        OutputStream os = 
StreamUtil.createOutputStream( target );<a name="line.119"></a>
+<span class="sourceLineNo">120</span>        InputStream dis = 
factory.getInputStream( is, password );<a name="line.120"></a>
+<span class="sourceLineNo">121</span>        StreamUtil.copy( dis, os );<a 
name="line.121"></a>
+<span class="sourceLineNo">122</span>    }<a name="line.122"></a>
+<span class="sourceLineNo">123</span><a name="line.123"></a>
+<span class="sourceLineNo">124</span>    /**<a name="line.124"></a>
+<span class="sourceLineNo">125</span>     * Encrypts a string into a hex 
string.<a name="line.125"></a>
+<span class="sourceLineNo">126</span>     *<a name="line.126"></a>
+<span class="sourceLineNo">127</span>     * @param plainText the plain text to 
be encrypted<a name="line.127"></a>
+<span class="sourceLineNo">128</span>     * @param password the password for 
encryption<a name="line.128"></a>
+<span class="sourceLineNo">129</span>     * @return the encrypted string<a 
name="line.129"></a>
+<span class="sourceLineNo">130</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.130"></a>
+<span class="sourceLineNo">131</span>     * @throws IOException accessing the 
souce failed<a name="line.131"></a>
+<span class="sourceLineNo">132</span>     */<a name="line.132"></a>
+<span class="sourceLineNo">133</span>    public static String encryptString( 
String plainText, char[] password )<a name="line.133"></a>
+<span class="sourceLineNo">134</span>        throws GeneralSecurityException, 
IOException<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>        return 
CryptoUtil.encryptString(<a name="line.136"></a>
+<span class="sourceLineNo">137</span>            
CryptoUtil.getCryptoStreamFactory(),<a name="line.137"></a>
+<span class="sourceLineNo">138</span>            plainText,<a 
name="line.138"></a>
+<span class="sourceLineNo">139</span>            password<a 
name="line.139"></a>
+<span class="sourceLineNo">140</span>            );<a name="line.140"></a>
+<span class="sourceLineNo">141</span>    }<a name="line.141"></a>
+<span class="sourceLineNo">142</span><a name="line.142"></a>
+<span class="sourceLineNo">143</span>    /**<a name="line.143"></a>
+<span class="sourceLineNo">144</span>     * Encrypts a string into a hex 
string.<a name="line.144"></a>
+<span class="sourceLineNo">145</span>     *<a name="line.145"></a>
+<span class="sourceLineNo">146</span>     * @param factory the factory to 
create the crypto streams<a name="line.146"></a>
+<span class="sourceLineNo">147</span>     * @param plainText the plain text to 
be encrypted<a name="line.147"></a>
+<span class="sourceLineNo">148</span>     * @param password the password for 
encryption<a name="line.148"></a>
+<span class="sourceLineNo">149</span>     * @return the encrypted string<a 
name="line.149"></a>
+<span class="sourceLineNo">150</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.150"></a>
+<span class="sourceLineNo">151</span>     * @throws IOException accessing the 
souce failed<a name="line.151"></a>
+<span class="sourceLineNo">152</span>     */<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    public static String encryptString(<a 
name="line.153"></a>
+<span class="sourceLineNo">154</span>        CryptoStreamFactory factory, 
String plainText, char[] password )<a name="line.154"></a>
+<span class="sourceLineNo">155</span>        throws GeneralSecurityException, 
IOException<a name="line.155"></a>
+<span class="sourceLineNo">156</span>    {<a name="line.156"></a>
+<span class="sourceLineNo">157</span>        ByteArrayOutputStream bais = new 
ByteArrayOutputStream();<a name="line.157"></a>
+<span class="sourceLineNo">158</span>        CryptoUtil.encrypt( factory, 
plainText, bais, password );<a name="line.158"></a>
+<span class="sourceLineNo">159</span>        return HexConverter.toString( 
bais.toByteArray() );<a name="line.159"></a>
+<span class="sourceLineNo">160</span>    }<a name="line.160"></a>
+<span class="sourceLineNo">161</span><a name="line.161"></a>
+<span class="sourceLineNo">162</span>    /**<a name="line.162"></a>
+<span class="sourceLineNo">163</span>     * Decrypts an encrypted string into 
the plain text. The encrypted<a name="line.163"></a>
+<span class="sourceLineNo">164</span>     * string must be a hex string 
created by encryptString.<a name="line.164"></a>
+<span class="sourceLineNo">165</span>     *<a name="line.165"></a>
+<span class="sourceLineNo">166</span>     * @param cipherText the encrypted 
text to be decrypted<a name="line.166"></a>
+<span class="sourceLineNo">167</span>     * @param password the password for 
decryption<a name="line.167"></a>
+<span class="sourceLineNo">168</span>     * @return the decrypted string<a 
name="line.168"></a>
+<span class="sourceLineNo">169</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.169"></a>
+<span class="sourceLineNo">170</span>     * @throws IOException accessing the 
souce failed<a name="line.170"></a>
+<span class="sourceLineNo">171</span>     */<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    public static String decryptString( 
String cipherText, char[] password )<a name="line.172"></a>
+<span class="sourceLineNo">173</span>        throws GeneralSecurityException, 
IOException<a name="line.173"></a>
+<span class="sourceLineNo">174</span>    {<a name="line.174"></a>
+<span class="sourceLineNo">175</span>        return 
CryptoUtil.decryptString(<a name="line.175"></a>
+<span class="sourceLineNo">176</span>            
CryptoUtil.getCryptoStreamFactory(),<a name="line.176"></a>
+<span class="sourceLineNo">177</span>            cipherText,<a 
name="line.177"></a>
+<span class="sourceLineNo">178</span>            password<a 
name="line.178"></a>
+<span class="sourceLineNo">179</span>            );<a name="line.179"></a>
+<span class="sourceLineNo">180</span>    }<a name="line.180"></a>
+<span class="sourceLineNo">181</span><a name="line.181"></a>
+<span class="sourceLineNo">182</span>    /**<a name="line.182"></a>
+<span class="sourceLineNo">183</span>     * Decrypts an encrypted string into 
the plain text. The encrypted<a name="line.183"></a>
+<span class="sourceLineNo">184</span>     * string must be a hex string 
created by encryptString.<a name="line.184"></a>
+<span class="sourceLineNo">185</span>     *<a name="line.185"></a>
+<span class="sourceLineNo">186</span>     * @param factory the factory to 
create the crypto streams<a name="line.186"></a>
+<span class="sourceLineNo">187</span>     * @param cipherText the encrypted 
text to be decrypted<a name="line.187"></a>
+<span class="sourceLineNo">188</span>     * @param password the password for 
decryption<a name="line.188"></a>
+<span class="sourceLineNo">189</span>     * @return the decrypted string<a 
name="line.189"></a>
+<span class="sourceLineNo">190</span>     * @throws GeneralSecurityException 
accessing JCE failed<a name="line.190"></a>
+<span class="sourceLineNo">191</span>     * @throws IOException accessing the 
souce failed<a name="line.191"></a>
+<span class="sourceLineNo">192</span>     */<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    public static String decryptString(<a 
name="line.193"></a>
+<span class="sourceLineNo">194</span>        CryptoStreamFactory factory, 
String cipherText, char[] password )<a name="line.194"></a>
+<span class="sourceLineNo">195</span>        throws GeneralSecurityException, 
IOException<a name="line.195"></a>
+<span class="sourceLineNo">196</span>    {<a name="line.196"></a>
+<span class="sourceLineNo">197</span>        byte[] buffer = 
HexConverter.toBytes( cipherText );<a name="line.197"></a>
+<span class="sourceLineNo">198</span>        ByteArrayOutputStream bais = new 
ByteArrayOutputStream();<a name="line.198"></a>
+<span class="sourceLineNo">199</span>        CryptoUtil.decrypt( factory, 
buffer, bais, password );<a name="line.199"></a>
+<span class="sourceLineNo">200</span>        return new String( 
bais.toByteArray(), "utf-8" );<a name="line.200"></a>
+<span class="sourceLineNo">201</span>    }<a name="line.201"></a>
+<span class="sourceLineNo">202</span><a name="line.202"></a>
+<span class="sourceLineNo">203</span>    /**<a name="line.203"></a>
+<span class="sourceLineNo">204</span>     * Pumps the input stream to the 
output stream.<a name="line.204"></a>
+<span class="sourceLineNo">205</span>     *<a name="line.205"></a>
+<span class="sourceLineNo">206</span>     * @param is the source input 
stream<a name="line.206"></a>
+<span class="sourceLineNo">207</span>     * @param os the target output 
stream<a name="line.207"></a>
+<span class="sourceLineNo">208</span>     * @return the number of bytes 
copied<a name="line.208"></a>
+<span class="sourceLineNo">209</span>     * @throws IOException the copying 
failed<a name="line.209"></a>
+<span class="sourceLineNo">210</span>     * @deprecated use StreamUtil 
instead<a name="line.210"></a>
+<span class="sourceLineNo">211</span>     */<a name="line.211"></a>
+<span class="sourceLineNo">212</span>    public static long copy( InputStream 
is, OutputStream os )<a name="line.212"></a>
+<span class="sourceLineNo">213</span>        throws IOException<a 
name="line.213"></a>
+<span class="sourceLineNo">214</span>    {<a name="line.214"></a>
+<span class="sourceLineNo">215</span>        return StreamUtil.copy(is, os);<a 
name="line.215"></a>
+<span class="sourceLineNo">216</span>    }<a name="line.216"></a>
+<span class="sourceLineNo">217</span><a name="line.217"></a>
+<span class="sourceLineNo">218</span>    /**<a name="line.218"></a>
+<span class="sourceLineNo">219</span>     * @return the CryptoStreamFactory to 
be used<a name="line.219"></a>
+<span class="sourceLineNo">220</span>     */<a name="line.220"></a>
+<span class="sourceLineNo">221</span>    public static CryptoStreamFactory 
getCryptoStreamFactory()<a name="line.221"></a>
+<span class="sourceLineNo">222</span>    {<a name="line.222"></a>
+<span class="sourceLineNo">223</span>        return 
CryptoStreamFactoryImpl.getInstance();<a name="line.223"></a>
+<span class="sourceLineNo">224</span>    }<a name="line.224"></a>
+<span class="sourceLineNo">225</span>}<a name="line.225"></a>
 
 
 
@@ -286,6 +291,7 @@
 
 
 
-</PRE>
-</BODY>
-</HTML>
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file

Modified: 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/HexConverter.html
==============================================================================
--- 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/HexConverter.html
 (original)
+++ 
websites/production/turbine/content/fulcrum/fulcrum-yaafi-crypto/apidocs/src-html/org/apache/fulcrum/jce/crypto/HexConverter.html
 Tue May 21 03:58:58 2019
@@ -1,180 +1,83 @@
-<HTML>
-<BODY BGCOLOR="white">
-<PRE>
-<FONT color="green">001</FONT>    package org.apache.fulcrum.jce.crypto;<a 
name="line.1"></a>
-<FONT color="green">002</FONT>    <a name="line.2"></a>
-<FONT color="green">003</FONT>    /*<a name="line.3"></a>
-<FONT color="green">004</FONT>     * Licensed to the Apache Software 
Foundation (ASF) under one<a name="line.4"></a>
-<FONT color="green">005</FONT>     * or more contributor license agreements.  
See the NOTICE file<a name="line.5"></a>
-<FONT color="green">006</FONT>     * distributed with this work for additional 
information<a name="line.6"></a>
-<FONT color="green">007</FONT>     * regarding copyright ownership.  The ASF 
licenses this file<a name="line.7"></a>
-<FONT color="green">008</FONT>     * to you under the Apache License, Version 
2.0 (the<a name="line.8"></a>
-<FONT color="green">009</FONT>     * "License"); you may not use this file 
except in compliance<a name="line.9"></a>
-<FONT color="green">010</FONT>     * with the License.  You may obtain a copy 
of the License at<a name="line.10"></a>
-<FONT color="green">011</FONT>     *<a name="line.11"></a>
-<FONT color="green">012</FONT>     *   
http://www.apache.org/licenses/LICENSE-2.0<a name="line.12"></a>
-<FONT color="green">013</FONT>     *<a name="line.13"></a>
-<FONT color="green">014</FONT>     * Unless required by applicable law or 
agreed to in writing,<a name="line.14"></a>
-<FONT color="green">015</FONT>     * software distributed under the License is 
distributed on an<a name="line.15"></a>
-<FONT color="green">016</FONT>     * "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY<a name="line.16"></a>
-<FONT color="green">017</FONT>     * KIND, either express or implied.  See the 
License for the<a name="line.17"></a>
-<FONT color="green">018</FONT>     * specific language governing permissions 
and limitations<a name="line.18"></a>
-<FONT color="green">019</FONT>     * under the License.<a name="line.19"></a>
-<FONT color="green">020</FONT>     */<a name="line.20"></a>
-<FONT color="green">021</FONT>    <a name="line.21"></a>
-<FONT color="green">022</FONT>    <a name="line.22"></a>
-<FONT color="green">023</FONT>    /**<a name="line.23"></a>
-<FONT color="green">024</FONT>     * Helper class to for HEX conversion.<a 
name="line.24"></a>
-<FONT color="green">025</FONT>     *<a name="line.25"></a>
-<FONT color="green">026</FONT>     * The code uses parts from Markus Hahn's 
Blowfish library found at<a name="line.26"></a>
-<FONT color="green">027</FONT>     * http://blowfishj.sourceforge.net/<a 
name="line.27"></a>
-<FONT color="green">028</FONT>     *<a name="line.28"></a>
-<FONT color="green">029</FONT>     * @author &lt;a 
href="mailto:[email protected]"&gt;Siegfried Goeschl &lt;/a&gt;<a 
name="line.29"></a>
-<FONT color="green">030</FONT>     * @author &lt;a 
href="mailto:[email protected]"&gt;Markus Hahn&lt;/a&gt;<a 
name="line.30"></a>
-<FONT color="green">031</FONT>     */<a name="line.31"></a>
-<FONT color="green">032</FONT>    <a name="line.32"></a>
-<FONT color="green">033</FONT>    public final class HexConverter<a 
name="line.33"></a>
-<FONT color="green">034</FONT>    {<a name="line.34"></a>
-<FONT color="green">035</FONT>        /**<a name="line.35"></a>
-<FONT color="green">036</FONT>         * Table for byte to hex conversion<a 
name="line.36"></a>
-<FONT color="green">037</FONT>         */<a name="line.37"></a>
-<FONT color="green">038</FONT>        final private static char[] HEXTAB =<a 
name="line.38"></a>
-<FONT color="green">039</FONT>        {<a name="line.39"></a>
-<FONT color="green">040</FONT>            '0', '1', '2', '3', '4', '5', '6', 
'7',<a name="line.40"></a>
-<FONT color="green">041</FONT>            '8', '9', 'a', 'b', 'c', 'd', 'e', 
'f'<a name="line.41"></a>
-<FONT color="green">042</FONT>        };<a name="line.42"></a>
-<FONT color="green">043</FONT>    <a name="line.43"></a>
-<FONT color="green">044</FONT>        /**<a name="line.44"></a>
-<FONT color="green">045</FONT>         * Converts a byte array to a hex 
string.<a name="line.45"></a>
-<FONT color="green">046</FONT>         *<a name="line.46"></a>
-<FONT color="green">047</FONT>         * @param data the byte array<a 
name="line.47"></a>
-<FONT color="green">048</FONT>         * @return the hex string<a 
name="line.48"></a>
-<FONT color="green">049</FONT>         */<a name="line.49"></a>
-<FONT color="green">050</FONT>        public static String toString( byte[] 
data )<a name="line.50"></a>
-<FONT color="green">051</FONT>        {<a name="line.51"></a>
-<FONT color="green">052</FONT>            return bytesToHexStr(data, 0, 
data.length);<a name="line.52"></a>
-<FONT color="green">053</FONT>        }<a name="line.53"></a>
-<FONT color="green">054</FONT>    <a name="line.54"></a>
-<FONT color="green">055</FONT>        /**<a name="line.55"></a>
-<FONT color="green">056</FONT>         * Converts a hex string into a byte[]<a 
name="line.56"></a>
-<FONT color="green">057</FONT>         *<a name="line.57"></a>
-<FONT color="green">058</FONT>         * @param data the hex string<a 
name="line.58"></a>
-<FONT color="green">059</FONT>         * @return the byte[]<a 
name="line.59"></a>
-<FONT color="green">060</FONT>         */<a name="line.60"></a>
-<FONT color="green">061</FONT>    <a name="line.61"></a>
-<FONT color="green">062</FONT>        public static byte[] toBytes( String 
data )<a name="line.62"></a>
-<FONT color="green">063</FONT>        {<a name="line.63"></a>
-<FONT color="green">064</FONT>            byte[] result = new 
byte[data.length()/2];<a name="line.64"></a>
-<FONT color="green">065</FONT>            hexStrToBytes( data, result, 0, 0, 
result.length );<a name="line.65"></a>
-<FONT color="green">066</FONT>            return result;<a name="line.66"></a>
-<FONT color="green">067</FONT>        }<a name="line.67"></a>
-<FONT color="green">068</FONT>    <a name="line.68"></a>
-<FONT color="green">069</FONT>        /**<a name="line.69"></a>
-<FONT color="green">070</FONT>         * Converts a byte array to a hex 
string.<a name="line.70"></a>
-<FONT color="green">071</FONT>         * @param data the byte array<a 
name="line.71"></a>
-<FONT color="green">072</FONT>         * @param nOfs start index where to get 
the bytes<a name="line.72"></a>
-<FONT color="green">073</FONT>         * @param nLen number of bytes to 
convert<a name="line.73"></a>
-<FONT color="green">074</FONT>         * @return the hex string<a 
name="line.74"></a>
-<FONT color="green">075</FONT>         */<a name="line.75"></a>
-<FONT color="green">076</FONT>        private static String bytesToHexStr(<a 
name="line.76"></a>
-<FONT color="green">077</FONT>            byte[] data,<a name="line.77"></a>
-<FONT color="green">078</FONT>            int nOfs,<a name="line.78"></a>
-<FONT color="green">079</FONT>            int nLen)<a name="line.79"></a>
-<FONT color="green">080</FONT>        {<a name="line.80"></a>
-<FONT color="green">081</FONT>            StringBuffer sbuf;<a 
name="line.81"></a>
-<FONT color="green">082</FONT>    <a name="line.82"></a>
-<FONT color="green">083</FONT>            sbuf = new StringBuffer();<a 
name="line.83"></a>
-<FONT color="green">084</FONT>            sbuf.setLength(nLen &lt;&lt; 1);<a 
name="line.84"></a>
-<FONT color="green">085</FONT>    <a name="line.85"></a>
-<FONT color="green">086</FONT>            int nPos = 0;<a name="line.86"></a>
-<FONT color="green">087</FONT>            int nC = nOfs + nLen;<a 
name="line.87"></a>
-<FONT color="green">088</FONT>    <a name="line.88"></a>
-<FONT color="green">089</FONT>            while (nOfs &lt; nC)<a 
name="line.89"></a>
-<FONT color="green">090</FONT>            {<a name="line.90"></a>
-<FONT color="green">091</FONT>                sbuf.setCharAt(nPos++, 
HEXTAB[(data[nOfs  ] &gt;&gt; 4) &amp; 0x0f]);<a name="line.91"></a>
-<FONT color="green">092</FONT>                sbuf.setCharAt(nPos++, HEXTAB[ 
data[nOfs++]       &amp; 0x0f]);<a name="line.92"></a>
-<FONT color="green">093</FONT>            }<a name="line.93"></a>
-<FONT color="green">094</FONT>    <a name="line.94"></a>
-<FONT color="green">095</FONT>            return sbuf.toString();<a 
name="line.95"></a>
-<FONT color="green">096</FONT>        }<a name="line.96"></a>
-<FONT color="green">097</FONT>    <a name="line.97"></a>
-<FONT color="green">098</FONT>        /**<a name="line.98"></a>
-<FONT color="green">099</FONT>         * Converts a hex string back into a 
byte array (invalid codes will be<a name="line.99"></a>
-<FONT color="green">100</FONT>         * skipped).<a name="line.100"></a>
-<FONT color="green">101</FONT>         * @param sHex hex string<a 
name="line.101"></a>
-<FONT color="green">102</FONT>         * @param data the target array<a 
name="line.102"></a>
-<FONT color="green">103</FONT>         * @param nSrcOfs from which character 
in the string the conversion should<a name="line.103"></a>
-<FONT color="green">104</FONT>         * begin, remember that (nSrcPos modulo 
2) should equals 0 normally<a name="line.104"></a>
-<FONT color="green">105</FONT>         * @param nDstOfs to store the bytes 
from which position in the array<a name="line.105"></a>
-<FONT color="green">106</FONT>         * @param nLen number of bytes to 
extract<a name="line.106"></a>
-<FONT color="green">107</FONT>         * @return number of extracted bytes<a 
name="line.107"></a>
-<FONT color="green">108</FONT>         */<a name="line.108"></a>
-<FONT color="green">109</FONT>        private static int hexStrToBytes(<a 
name="line.109"></a>
-<FONT color="green">110</FONT>            String sHex,<a name="line.110"></a>
-<FONT color="green">111</FONT>            byte[] data,<a name="line.111"></a>
-<FONT color="green">112</FONT>            int nSrcOfs,<a name="line.112"></a>
-<FONT color="green">113</FONT>            int nDstOfs,<a name="line.113"></a>
-<FONT color="green">114</FONT>            int nLen)<a name="line.114"></a>
-<FONT color="green">115</FONT>        {<a name="line.115"></a>
-<FONT color="green">116</FONT>            int nI, nJ, nStrLen, nAvailBytes, 
nDstOfsBak;<a name="line.116"></a>
-<FONT color="green">117</FONT>            byte bActByte;<a name="line.117"></a>
-<FONT color="green">118</FONT>            boolean blConvertOK;<a 
name="line.118"></a>
-<FONT color="green">119</FONT>    <a name="line.119"></a>
-<FONT color="green">120</FONT>            // check for correct ranges<a 
name="line.120"></a>
-<FONT color="green">121</FONT>    <a name="line.121"></a>
-<FONT color="green">122</FONT>            nStrLen = sHex.length();<a 
name="line.122"></a>
-<FONT color="green">123</FONT>    <a name="line.123"></a>
-<FONT color="green">124</FONT>            nAvailBytes = (nStrLen - nSrcOfs) 
&gt;&gt; 1;<a name="line.124"></a>
-<FONT color="green">125</FONT>            if (nAvailBytes &lt; nLen)<a 
name="line.125"></a>
-<FONT color="green">126</FONT>            {<a name="line.126"></a>
-<FONT color="green">127</FONT>                nLen = nAvailBytes;<a 
name="line.127"></a>
-<FONT color="green">128</FONT>            }<a name="line.128"></a>
-<FONT color="green">129</FONT>    <a name="line.129"></a>
-<FONT color="green">130</FONT>            int nOutputCapacity = data.length - 
nDstOfs;<a name="line.130"></a>
-<FONT color="green">131</FONT>            if (nLen &gt; nOutputCapacity)<a 
name="line.131"></a>
-<FONT color="green">132</FONT>            {<a name="line.132"></a>
-<FONT color="green">133</FONT>                nLen = nOutputCapacity;<a 
name="line.133"></a>
-<FONT color="green">134</FONT>            }<a name="line.134"></a>
-<FONT color="green">135</FONT>    <a name="line.135"></a>
-<FONT color="green">136</FONT>            // convert now<a name="line.136"></a>
-<FONT color="green">137</FONT>    <a name="line.137"></a>
-<FONT color="green">138</FONT>            nDstOfsBak = nDstOfs;<a 
name="line.138"></a>
-<FONT color="green">139</FONT>    <a name="line.139"></a>
-<FONT color="green">140</FONT>            for (nI = 0; nI &lt; nLen; nI++)<a 
name="line.140"></a>
-<FONT color="green">141</FONT>            {<a name="line.141"></a>
-<FONT color="green">142</FONT>                bActByte = 0;<a 
name="line.142"></a>
-<FONT color="green">143</FONT>                blConvertOK = true;<a 
name="line.143"></a>
-<FONT color="green">144</FONT>    <a name="line.144"></a>
-<FONT color="green">145</FONT>                for (nJ = 0; nJ &lt; 2; nJ++)<a 
name="line.145"></a>
-<FONT color="green">146</FONT>                {<a name="line.146"></a>
-<FONT color="green">147</FONT>                    bActByte &lt;&lt;= 4;<a 
name="line.147"></a>
-<FONT color="green">148</FONT>                    char cActChar = 
sHex.charAt(nSrcOfs++);<a name="line.148"></a>
-<FONT color="green">149</FONT>    <a name="line.149"></a>
-<FONT color="green">150</FONT>                    if ((cActChar &gt;= 'a') 
&amp;&amp; (cActChar &lt;= 'f'))<a name="line.150"></a>
-<FONT color="green">151</FONT>                    {<a name="line.151"></a>
-<FONT color="green">152</FONT>                        bActByte |= (byte) 
(cActChar - 'a') + 10;<a name="line.152"></a>
-<FONT color="green">153</FONT>                    }<a name="line.153"></a>
-<FONT color="green">154</FONT>                    else<a name="line.154"></a>
-<FONT color="green">155</FONT>                    {<a name="line.155"></a>
-<FONT color="green">156</FONT>                        if ((cActChar &gt;= '0') 
&amp;&amp; (cActChar &lt;= '9'))<a name="line.156"></a>
-<FONT color="green">157</FONT>                        {<a name="line.157"></a>
-<FONT color="green">158</FONT>                            bActByte |= (byte) 
(cActChar - '0');<a name="line.158"></a>
-<FONT color="green">159</FONT>                        }<a name="line.159"></a>
-<FONT color="green">160</FONT>                        else<a 
name="line.160"></a>
-<FONT color="green">161</FONT>                        {<a name="line.161"></a>
-<FONT color="green">162</FONT>                            blConvertOK = 
false;<a name="line.162"></a>
-<FONT color="green">163</FONT>                        }<a name="line.163"></a>
-<FONT color="green">164</FONT>                    }<a name="line.164"></a>
-<FONT color="green">165</FONT>                }<a name="line.165"></a>
-<FONT color="green">166</FONT>                if (blConvertOK)<a 
name="line.166"></a>
-<FONT color="green">167</FONT>                {<a name="line.167"></a>
-<FONT color="green">168</FONT>                    data[nDstOfs++] = 
bActByte;<a name="line.168"></a>
-<FONT color="green">169</FONT>                }<a name="line.169"></a>
-<FONT color="green">170</FONT>            }<a name="line.170"></a>
-<FONT color="green">171</FONT>    <a name="line.171"></a>
-<FONT color="green">172</FONT>            return (nDstOfs - nDstOfsBak);<a 
name="line.172"></a>
-<FONT color="green">173</FONT>        }<a name="line.173"></a>
-<FONT color="green">174</FONT>    }<a name="line.174"></a>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<html lang="en">
+<head>
+<title>Source code</title>
+<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" 
title="Style">
+</head>
+<body>
+<div class="sourceContainer">
+<pre><span class="sourceLineNo">001</span>package 
org.apache.fulcrum.jce.crypto;<a name="line.1"></a>
+<span class="sourceLineNo">002</span><a name="line.2"></a>
+<span class="sourceLineNo">003</span>/*<a name="line.3"></a>
+<span class="sourceLineNo">004</span> * Licensed to the Apache Software 
Foundation (ASF) under one<a name="line.4"></a>
+<span class="sourceLineNo">005</span> * or more contributor license 
agreements.  See the NOTICE file<a name="line.5"></a>
+<span class="sourceLineNo">006</span> * distributed with this work for 
additional information<a name="line.6"></a>
+<span class="sourceLineNo">007</span> * regarding copyright ownership.  The 
ASF licenses this file<a name="line.7"></a>
+<span class="sourceLineNo">008</span> * to you under the Apache License, 
Version 2.0 (the<a name="line.8"></a>
+<span class="sourceLineNo">009</span> * "License"); you may not use this file 
except in compliance<a name="line.9"></a>
+<span class="sourceLineNo">010</span> * with the License.  You may obtain a 
copy of the License at<a name="line.10"></a>
+<span class="sourceLineNo">011</span> *<a name="line.11"></a>
+<span class="sourceLineNo">012</span> *   
http://www.apache.org/licenses/LICENSE-2.0<a name="line.12"></a>
+<span class="sourceLineNo">013</span> *<a name="line.13"></a>
+<span class="sourceLineNo">014</span> * Unless required by applicable law or 
agreed to in writing,<a name="line.14"></a>
+<span class="sourceLineNo">015</span> * software distributed under the License 
is distributed on an<a name="line.15"></a>
+<span class="sourceLineNo">016</span> * "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY<a name="line.16"></a>
+<span class="sourceLineNo">017</span> * KIND, either express or implied.  See 
the License for the<a name="line.17"></a>
+<span class="sourceLineNo">018</span> * specific language governing 
permissions and limitations<a name="line.18"></a>
+<span class="sourceLineNo">019</span> * under the License.<a 
name="line.19"></a>
+<span class="sourceLineNo">020</span> */<a name="line.20"></a>
+<span class="sourceLineNo">021</span><a name="line.21"></a>
+<span class="sourceLineNo">022</span>/**<a name="line.22"></a>
+<span class="sourceLineNo">023</span> * Helper class to for HEX conversion.<a 
name="line.23"></a>
+<span class="sourceLineNo">024</span> *<a name="line.24"></a>
+<span class="sourceLineNo">025</span> * @author &lt;a 
href="mailto:[email protected]"&gt;Jeffery Painter&lt;/a&gt;<a 
name="line.25"></a>
+<span class="sourceLineNo">026</span> * @author &lt;a 
href="mailto:[email protected]"&gt;Siegfried Goeschl&lt;/a&gt;<a 
name="line.26"></a>
+<span class="sourceLineNo">027</span> * @author &lt;a 
href="mailto:[email protected]"&gt;Markus Hahn&lt;/a&gt;<a 
name="line.27"></a>
+<span class="sourceLineNo">028</span> */<a name="line.28"></a>
+<span class="sourceLineNo">029</span><a name="line.29"></a>
+<span class="sourceLineNo">030</span>public final class HexConverter<a 
name="line.30"></a>
+<span class="sourceLineNo">031</span>{<a name="line.31"></a>
+<span class="sourceLineNo">032</span>    /**<a name="line.32"></a>
+<span class="sourceLineNo">033</span>     * Converts a byte array to a hex 
string.<a name="line.33"></a>
+<span class="sourceLineNo">034</span>     *<a name="line.34"></a>
+<span class="sourceLineNo">035</span>     * @param data the byte array<a 
name="line.35"></a>
+<span class="sourceLineNo">036</span>     * @return the hex string<a 
name="line.36"></a>
+<span class="sourceLineNo">037</span>     */<a name="line.37"></a>
+<span class="sourceLineNo">038</span>    public static String toString( byte[] 
data )<a name="line.38"></a>
+<span class="sourceLineNo">039</span>    {<a name="line.39"></a>
+<span class="sourceLineNo">040</span>        return bytesToHexStr(data);<a 
name="line.40"></a>
+<span class="sourceLineNo">041</span>    }<a name="line.41"></a>
+<span class="sourceLineNo">042</span><a name="line.42"></a>
+<span class="sourceLineNo">043</span>    /**<a name="line.43"></a>
+<span class="sourceLineNo">044</span>     * Converts a hex string into a 
byte[]<a name="line.44"></a>
+<span class="sourceLineNo">045</span>     *<a name="line.45"></a>
+<span class="sourceLineNo">046</span>     * @param sHex the hex string<a 
name="line.46"></a>
+<span class="sourceLineNo">047</span>     * @return the byte[]<a 
name="line.47"></a>
+<span class="sourceLineNo">048</span>     */<a name="line.48"></a>
+<span class="sourceLineNo">049</span>    public static byte[] toBytes(String 
sHex) {<a name="line.49"></a>
+<span class="sourceLineNo">050</span>        int len = sHex.length();<a 
name="line.50"></a>
+<span class="sourceLineNo">051</span>        byte[] data = new byte[len / 
2];<a name="line.51"></a>
+<span class="sourceLineNo">052</span>        for (int i = 0; i &lt; len; i += 
2) {<a name="line.52"></a>
+<span class="sourceLineNo">053</span>            data[i / 2] = (byte) 
((Character.digit(sHex.charAt(i), 16) &lt;&lt; 4)<a name="line.53"></a>
+<span class="sourceLineNo">054</span>                                 + 
Character.digit(sHex.charAt(i+1), 16));<a name="line.54"></a>
+<span class="sourceLineNo">055</span>        }<a name="line.55"></a>
+<span class="sourceLineNo">056</span>        return data;<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    }    <a name="line.57"></a>
+<span class="sourceLineNo">058</span>    <a name="line.58"></a>
+<span class="sourceLineNo">059</span>    /**<a name="line.59"></a>
+<span class="sourceLineNo">060</span>     * Converts a byte array to a hex 
string.<a name="line.60"></a>
+<span class="sourceLineNo">061</span>     * @param data the byte array<a 
name="line.61"></a>
+<span class="sourceLineNo">062</span>     * @return the hex string<a 
name="line.62"></a>
+<span class="sourceLineNo">063</span>     */<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    private static String bytesToHexStr( 
byte[] data )<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    {<a name="line.65"></a>
+<span class="sourceLineNo">066</span>        StringBuilder sbuf = new 
StringBuilder();<a name="line.66"></a>
+<span class="sourceLineNo">067</span>        for ( byte b : data )<a 
name="line.67"></a>
+<span class="sourceLineNo">068</span>                sbuf.append( 
String.format("%02x", b ) );<a name="line.68"></a>
+<span class="sourceLineNo">069</span>        return sbuf.toString();<a 
name="line.69"></a>
+<span class="sourceLineNo">070</span>    }<a name="line.70"></a>
+<span class="sourceLineNo">071</span><a name="line.71"></a>
+<span class="sourceLineNo">072</span>}<a name="line.72"></a>
 
 
 
@@ -235,6 +138,7 @@
 
 
 
-</PRE>
-</BODY>
-</HTML>
+</pre>
+</div>
+</body>
+</html>
\ No newline at end of file


Reply via email to