blob: 73c0365c72defdfed48393a3929c63ca202cb66b [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_21) on Thu May 30 14:51:24 PDT 2013 -->
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<title>JcaCipherService (Apache Shiro 1.2.1 API)</title>
<meta name="date" content="2013-05-30">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="JcaCipherService (Apache Shiro 1.2.1 API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/JcaCipherService.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/shiro/crypto/DefaultBlockCipherService.html" title="class in org.apache.shiro.crypto"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/shiro/crypto/OperationMode.html" title="enum in org.apache.shiro.crypto"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/shiro/crypto/JcaCipherService.html" target="_top">Frames</a></li>
<li><a href="JcaCipherService.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.shiro.crypto</div>
<h2 title="Class JcaCipherService" class="title">Class JcaCipherService</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>org.apache.shiro.crypto.JcaCipherService</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:</dt>
<dd><a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></dd>
</dl>
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../org/apache/shiro/crypto/AbstractSymmetricCipherService.html" title="class in org.apache.shiro.crypto">AbstractSymmetricCipherService</a></dd>
</dl>
<hr>
<br>
<pre>public abstract class <a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.69">JcaCipherService</a>
extends <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a>
implements <a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></pre>
<div class="block">Abstract <code>CipherService</code> implementation utilizing Java's JCA APIs.
<h2>Auto-generated Initialization Vectors</h2>
Shiro does something by default for all of its <code>CipherService</code> implementations that the JCA
<a href="http://java.sun.com/javase/6/docs/api/javax/crypto/Cipher.html?is-external=true" title="class or interface in javax.crypto"><code>Cipher</code></a> does not do: by default,
<a href="http://en.wikipedia.org/wiki/Initialization_vector">initialization vector</a>s are automatically randomly
generated and prepended to encrypted data before returning from the <code>encrypt</code> methods. That is, the returned
byte array or <code>OutputStream</code> is actually a concatenation of an initialization vector byte array plus the actual
encrypted data byte array. The <code>decrypt</code> methods in turn know to read this prepended initialization vector
before decrypting the real data that follows.
<p/>
This is highly desirable because initialization vectors guarantee that, for a key and any plaintext, the encrypted
output will always be different <em>even if you call <code>encrypt</code> multiple times with the exact same arguments</em>.
This is essential in cryptography to ensure that data patterns cannot be identified across multiple input sources
that are the same or similar.
<p/>
You can turn off this behavior by setting the
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setGenerateInitializationVectors(boolean)"><code>generateInitializationVectors</code></a> property to <code>false</code>, but it
is highly recommended that you do not do this unless you have a very good reason to do so, since you would be losing
a critical security feature.
<h3>Initialization Vector Size</h3>
This implementation defaults the <a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setInitializationVectorSize(int)"><code>initializationVectorSize</code></a> attribute to
<code>128</code> bits, a fairly common size. Initialization vector sizes are very algorithm specific however, so subclass
implementations will often override this value in their constructor if necessary.
<p/>
Also note that <code>initializationVectorSize</code> values are specified in the number of
bits (not bytes!) to match common references in most cryptography documentation. In practice though, initialization
vectors are always specified as a byte array, so ensure that if you set this property, that the value is a multiple
of <code>8</code> to ensure that the IV can be correctly represented as a byte array (the
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setInitializationVectorSize(int)"><code>setInitializationVectorSize</code></a> mutator method enforces this).</div>
<dl><dt><span class="strong">Since:</span></dt>
<dd>1.0</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier</th>
<th class="colLast" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected </code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#JcaCipherService(java.lang.String)">JcaCipherService</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;algorithmName)</code>
<div class="block">Creates a new <code>JcaCipherService</code> instance which will use the specified cipher <code>algorithmName</code>
for all encryption, decryption, and key operations.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(byte[], byte[])">decrypt</a></strong>(byte[]&nbsp;ciphertext,
byte[]&nbsp;key)</code>
<div class="block">Decrypts encrypted data via the specified cipher key and returns the original (pre-encrypted) data.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">decrypt</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in,
<a href="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out,
byte[]&nbsp;key)</code>
<div class="block">Receives encrypted data from the given <code>InputStream</code>, decrypts it, and sends the resulting decrypted data
to the given <code>OutputStream</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(byte[], byte[])">encrypt</a></strong>(byte[]&nbsp;plaintext,
byte[]&nbsp;key)</code>
<div class="block">Encrypts data via the specified cipher key.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">encrypt</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in,
<a href="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out,
byte[]&nbsp;key)</code>
<div class="block">Receives the data from the given <code>InputStream</code>, encrypts it, and sends the resulting encrypted data to the
given <code>OutputStream</code>.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected <a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#ensureSecureRandom()">ensureSecureRandom</a></strong>()</code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected byte[]</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#generateInitializationVector(boolean)">generateInitializationVector</a></strong>(boolean&nbsp;streaming)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getAlgorithmName()">getAlgorithmName</a></strong>()</code>
<div class="block">Returns the cipher algorithm name that will be used for all encryption, decryption, and key operations (for
example, 'AES', 'Blowfish', 'RSA', 'DSA', 'TripleDES', etc).</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>protected static <a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getDefaultSecureRandom()">getDefaultSecureRandom</a></strong>()</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getInitializationVectorSize()">getInitializationVectorSize</a></strong>()</code>
<div class="block">Returns the algorithm-specific size in bits of generated initialization vectors.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getKeySize()">getKeySize</a></strong>()</code>
<div class="block">Returns the size in bits (not bytes) of generated cipher keys.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getSecureRandom()">getSecureRandom</a></strong>()</code>
<div class="block">Returns a source of randomness for encryption operations.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getStreamingBufferSize()">getStreamingBufferSize</a></strong>()</code>
<div class="block">Returns the size in bytes of the internal buffer used to transfer data from one stream to another during stream
operations (<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>encrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a> and
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>decrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a>).</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getTransformationString(boolean)">getTransformationString</a></strong>(boolean&nbsp;streaming)</code>
<div class="block">Returns the transformation string to use with the <a href="http://java.sun.com/javase/6/docs/api/javax/crypto/Cipher.html?is-external=true#getInstance(java.lang.String)" title="class or interface in javax.crypto"><code>Cipher.getInstance(java.lang.String)</code></a> invocation when
creating a new <code>Cipher</code> instance.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#isGenerateInitializationVectors()">isGenerateInitializationVectors</a></strong>()</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>protected boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#isGenerateInitializationVectors(boolean)">isGenerateInitializationVectors</a></strong>(boolean&nbsp;streaming)</code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setGenerateInitializationVectors(boolean)">setGenerateInitializationVectors</a></strong>(boolean&nbsp;generateInitializationVectors)</code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setInitializationVectorSize(int)">setInitializationVectorSize</a></strong>(int&nbsp;initializationVectorSize)</code>
<div class="block">Sets the algorithm-specific initialization vector size in bits (not bytes!) to be used when generating
initialization vectors.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setKeySize(int)">setKeySize</a></strong>(int&nbsp;keySize)</code>
<div class="block">Sets the size in bits (not bytes) of generated cipher keys.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setSecureRandom(java.security.SecureRandom)">setSecureRandom</a></strong>(<a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a>&nbsp;secureRandom)</code>
<div class="block">Sets a source of randomness for encryption operations.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setStreamingBufferSize(int)">setStreamingBufferSize</a></strong>(int&nbsp;streamingBufferSize)</code>
<div class="block">Sets the size in bytes of the internal buffer used to transfer data from one stream to another during stream
operations (<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>encrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a> and
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>decrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a>).</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</a>, <a href="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="JcaCipherService(java.lang.String)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>JcaCipherService</h4>
<pre>protected&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.125">JcaCipherService</a>(<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;algorithmName)</pre>
<div class="block">Creates a new <code>JcaCipherService</code> instance which will use the specified cipher <code>algorithmName</code>
for all encryption, decryption, and key operations. Also, the following defaults are set:
<ul>
<li><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setKeySize(int)"><code>keySize</code></a> = 128 bits</li>
<li><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setInitializationVectorSize(int)"><code>initializationVectorSize</code></a> = 128 bits</li>
<li><a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#setStreamingBufferSize(int)"><code>streamingBufferSize</code></a> = 512 bytes</li>
</ul></div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>algorithmName</code> - the name of the cipher algorithm to use for all encryption, decryption, and key operations</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="getAlgorithmName()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getAlgorithmName</h4>
<pre>public&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.142">getAlgorithmName</a>()</pre>
<div class="block">Returns the cipher algorithm name that will be used for all encryption, decryption, and key operations (for
example, 'AES', 'Blowfish', 'RSA', 'DSA', 'TripleDES', etc).</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the cipher algorithm name that will be used for all encryption, decryption, and key operations</dd></dl>
</li>
</ul>
<a name="getKeySize()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getKeySize</h4>
<pre>public&nbsp;int&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.151">getKeySize</a>()</pre>
<div class="block">Returns the size in bits (not bytes) of generated cipher keys.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the size in bits (not bytes) of generated cipher keys.</dd></dl>
</li>
</ul>
<a name="setKeySize(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setKeySize</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.160">setKeySize</a>(int&nbsp;keySize)</pre>
<div class="block">Sets the size in bits (not bytes) of generated cipher keys.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>keySize</code> - the size in bits (not bytes) of generated cipher keys.</dd></dl>
</li>
</ul>
<a name="isGenerateInitializationVectors()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isGenerateInitializationVectors</h4>
<pre>public&nbsp;boolean&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.164">isGenerateInitializationVectors</a>()</pre>
</li>
</ul>
<a name="setGenerateInitializationVectors(boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setGenerateInitializationVectors</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.168">setGenerateInitializationVectors</a>(boolean&nbsp;generateInitializationVectors)</pre>
</li>
</ul>
<a name="getInitializationVectorSize()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInitializationVectorSize</h4>
<pre>public&nbsp;int&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.177">getInitializationVectorSize</a>()</pre>
<div class="block">Returns the algorithm-specific size in bits of generated initialization vectors.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the algorithm-specific size in bits of generated initialization vectors.</dd></dl>
</li>
</ul>
<a name="setInitializationVectorSize(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setInitializationVectorSize</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.189">setInitializationVectorSize</a>(int&nbsp;initializationVectorSize)
throws <a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></pre>
<div class="block">Sets the algorithm-specific initialization vector size in bits (not bytes!) to be used when generating
initialization vectors. The value must be a multiple of <code>8</code> to ensure that the IV can be represented
as a byte array.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>initializationVectorSize</code> - the size in bits (not bytes) of generated initialization vectors.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if the size is not a multiple of <code>8</code>.</dd></dl>
</li>
</ul>
<a name="isGenerateInitializationVectors(boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>isGenerateInitializationVectors</h4>
<pre>protected&nbsp;boolean&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.198">isGenerateInitializationVectors</a>(boolean&nbsp;streaming)</pre>
</li>
</ul>
<a name="getStreamingBufferSize()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getStreamingBufferSize</h4>
<pre>public&nbsp;int&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.212">getStreamingBufferSize</a>()</pre>
<div class="block">Returns the size in bytes of the internal buffer used to transfer data from one stream to another during stream
operations (<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>encrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a> and
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>decrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a>).
<p/>
Default size is <code>512</code> bytes.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>the size of the internal buffer used to transfer data from one stream to another during stream
operations</dd></dl>
</li>
</ul>
<a name="setStreamingBufferSize(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setStreamingBufferSize</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.226">setStreamingBufferSize</a>(int&nbsp;streamingBufferSize)</pre>
<div class="block">Sets the size in bytes of the internal buffer used to transfer data from one stream to another during stream
operations (<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>encrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a> and
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])"><code>decrypt(java.io.InputStream, java.io.OutputStream, byte[])</code></a>).
<p/>
Default size is <code>512</code> bytes.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>streamingBufferSize</code> - the size of the internal buffer used to transfer data from one stream to another
during stream operations</dd></dl>
</li>
</ul>
<a name="getSecureRandom()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getSecureRandom</h4>
<pre>public&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.237">getSecureRandom</a>()</pre>
<div class="block">Returns a source of randomness for encryption operations. If one is not configured, and the underlying
algorithm needs one, the JDK <code>SHA1PRNG</code> instance will be used by default.</div>
<dl><dt><span class="strong">Returns:</span></dt><dd>a source of randomness for encryption operations. If one is not configured, and the underlying
algorithm needs one, the JDK <code>SHA1PRNG</code> instance will be used by default.</dd></dl>
</li>
</ul>
<a name="setSecureRandom(java.security.SecureRandom)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setSecureRandom</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.248">setSecureRandom</a>(<a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a>&nbsp;secureRandom)</pre>
<div class="block">Sets a source of randomness for encryption operations. If one is not configured, and the underlying
algorithm needs one, the JDK <code>SHA1PRNG</code> instance will be used by default.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>secureRandom</code> - a source of randomness for encryption operations. If one is not configured, and the
underlying algorithm needs one, the JDK <code>SHA1PRNG</code> instance will be used by default.</dd></dl>
</li>
</ul>
<a name="getDefaultSecureRandom()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDefaultSecureRandom</h4>
<pre>protected static&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.252">getDefaultSecureRandom</a>()</pre>
</li>
</ul>
<a name="ensureSecureRandom()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ensureSecureRandom</h4>
<pre>protected&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/security/SecureRandom.html?is-external=true" title="class or interface in java.security">SecureRandom</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.262">ensureSecureRandom</a>()</pre>
</li>
</ul>
<a name="getTransformationString(boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTransformationString</h4>
<pre>protected&nbsp;<a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.280">getTransformationString</a>(boolean&nbsp;streaming)</pre>
<div class="block">Returns the transformation string to use with the <a href="http://java.sun.com/javase/6/docs/api/javax/crypto/Cipher.html?is-external=true#getInstance(java.lang.String)" title="class or interface in javax.crypto"><code>Cipher.getInstance(java.lang.String)</code></a> invocation when
creating a new <code>Cipher</code> instance. This default implementation always returns
<a href="../../../../org/apache/shiro/crypto/JcaCipherService.html#getAlgorithmName()"><code>getAlgorithmName()</code></a>. Block cipher implementations will want to override this method
to support appending cipher operation modes and padding schemes.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>streaming</code> - if the transformation string is going to be used for a Cipher for stream-based encryption or not.</dd>
<dt><span class="strong">Returns:</span></dt><dd>the transformation string to use with the <a href="http://java.sun.com/javase/6/docs/api/javax/crypto/Cipher.html?is-external=true#getInstance(java.lang.String)" title="class or interface in javax.crypto"><code>Cipher.getInstance(java.lang.String)</code></a> invocation when
creating a new <code>Cipher</code> instance.</dd></dl>
</li>
</ul>
<a name="generateInitializationVector(boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>generateInitializationVector</h4>
<pre>protected&nbsp;byte[]&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.284">generateInitializationVector</a>(boolean&nbsp;streaming)</pre>
</li>
</ul>
<a name="encrypt(byte[], byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>encrypt</h4>
<pre>public&nbsp;<a href="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.303">encrypt</a>(byte[]&nbsp;plaintext,
byte[]&nbsp;key)</pre>
<div class="block"><strong>Description copied from interface:&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(byte[], byte[])">CipherService</a></code></strong></div>
<div class="block">Encrypts data via the specified cipher key. Note that the key must be in a format understood by
the <code>CipherService</code> implementation.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(byte[], byte[])">encrypt</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>plaintext</code> - the data to encrypt</dd><dd><code>key</code> - the cipher key used during encryption.</dd>
<dt><span class="strong">Returns:</span></dt><dd>a byte source with the encrypted representation of the specified raw data.</dd></dl>
</li>
</ul>
<a name="decrypt(byte[], byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>decrypt</h4>
<pre>public&nbsp;<a href="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</a>&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.347">decrypt</a>(byte[]&nbsp;ciphertext,
byte[]&nbsp;key)
throws <a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></pre>
<div class="block"><strong>Description copied from interface:&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(byte[], byte[])">CipherService</a></code></strong></div>
<div class="block">Decrypts encrypted data via the specified cipher key and returns the original (pre-encrypted) data.
Note that the key must be in a format understood by the CipherService implementation.</div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(byte[], byte[])">decrypt</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>ciphertext</code> - the previously encrypted data to decrypt</dd><dd><code>key</code> - the cipher key used during decryption.</dd>
<dt><span class="strong">Returns:</span></dt><dd>a byte source representing the original form of the specified encrypted data.</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></code> - if there is an error during decryption</dd></dl>
</li>
</ul>
<a name="encrypt(java.io.InputStream, java.io.OutputStream, byte[])">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>encrypt</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.500">encrypt</a>(<a href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in,
<a href="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out,
byte[]&nbsp;key)
throws <a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></pre>
<div class="block"><strong>Description copied from interface:&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">CipherService</a></code></strong></div>
<div class="block">Receives the data from the given <code>InputStream</code>, encrypts it, and sends the resulting encrypted data to the
given <code>OutputStream</code>.
<p/>
<b>NOTE:</b> This method <em>does NOT</em> flush or close either stream prior to returning - the caller must
do so when they are finished with the streams. For example:
<pre>
try {
InputStream in = ...
OutputStream out = ...
cipherService.encrypt(in, out, encryptionKey);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe1) { ... log, trigger event, etc }
}
if (out != null) {
try {
out.close();
} catch (IOException ioe2) { ... log, trigger event, etc }
}
}
</pre></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">encrypt</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>in</code> - the stream supplying the data to encrypt</dd><dd><code>out</code> - the stream to send the encrypted data</dd><dd><code>key</code> - the cipher key to use for encryption</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></code> - if there is any problem during encryption.</dd></dl>
</li>
</ul>
<a name="decrypt(java.io.InputStream, java.io.OutputStream, byte[])">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>decrypt</h4>
<pre>public&nbsp;void&nbsp;<a href="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.526">decrypt</a>(<a href="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in,
<a href="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out,
byte[]&nbsp;key)
throws <a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></pre>
<div class="block"><strong>Description copied from interface:&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">CipherService</a></code></strong></div>
<div class="block">Receives encrypted data from the given <code>InputStream</code>, decrypts it, and sends the resulting decrypted data
to the given <code>OutputStream</code>.
<p/>
<b>NOTE:</b> This method <em>does NOT</em> flush or close either stream prior to returning - the caller must
do so when they are finished with the streams. For example:
<pre>
try {
InputStream in = ...
OutputStream out = ...
cipherService.decrypt(in, out, decryptionKey);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe1) { ... log, trigger event, etc }
}
if (out != null) {
try {
out.close();
} catch (IOException ioe2) { ... log, trigger event, etc }
}
}
</pre></div>
<dl>
<dt><strong>Specified by:</strong></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">decrypt</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</a></code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>in</code> - the stream supplying the data to decrypt</dd><dd><code>out</code> - the stream to send the decrypted data</dd><dd><code>key</code> - the cipher key to use for decryption</dd>
<dt><span class="strong">Throws:</span></dt>
<dd><code><a href="../../../../org/apache/shiro/crypto/CryptoException.html" title="class in org.apache.shiro.crypto">CryptoException</a></code> - if there is any problem during decryption.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/JcaCipherService.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/shiro/crypto/DefaultBlockCipherService.html" title="class in org.apache.shiro.crypto"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../org/apache/shiro/crypto/OperationMode.html" title="enum in org.apache.shiro.crypto"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/shiro/crypto/JcaCipherService.html" target="_top">Frames</a></li>
<li><a href="JcaCipherService.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2004-2013 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.</small></p>
</body>
</html>