blob: f03d8ab09114e3bbc58d023f86880d75099fb2da [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0_65) on Tue Feb 25 18:15:47 EST 2014 -->
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>
JcaCipherService (Apache Shiro 1.2.3 API)
</TITLE>
<META NAME="date" CONTENT="2014-02-25">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="JcaCipherService (Apache Shiro 1.2.3 API)";
}
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<HR>
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JcaCipherService.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/crypto/DefaultBlockCipherService.html" title="class in org.apache.shiro.crypto"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/crypto/OperationMode.html" title="enum in org.apache.shiro.crypto"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/crypto/JcaCipherService.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="JcaCipherService.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
org.apache.shiro.crypto</FONT>
<BR>
Class JcaCipherService</H2>
<PRE>
<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>
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>org.apache.shiro.crypto.JcaCipherService</B>
</PRE>
<DL>
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></DD>
</DL>
<DL>
<DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../../org/apache/shiro/crypto/AbstractSymmetricCipherService.html" title="class in org.apache.shiro.crypto">AbstractSymmetricCipherService</A></DD>
</DL>
<HR>
<DL>
<DT><PRE>public abstract class <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.69"><B>JcaCipherService</B></A><DT>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><DT>implements <A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></DL>
</PRE>
<P>
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).
<P>
<P>
<DL>
<DT><B>Since:</B></DT>
<DD>1.0</DD>
</DL>
<HR>
<P>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected </CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#JcaCipherService(java.lang.String)">JcaCipherService</A></B>(<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>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Creates a new <code>JcaCipherService</code> instance which will use the specified cipher <code>algorithmName</code>
for all encryption, decryption, and key operations.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->
<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(byte[], byte[])">decrypt</A></B>(byte[]&nbsp;ciphertext,
byte[]&nbsp;key)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Decrypts encrypted data via the specified cipher key and returns the original (pre-encrypted) data.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">decrypt</A></B>(<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>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receives encrypted data from the given <code>InputStream</code>, decrypts it, and sends the resulting decrypted data
to the given <code>OutputStream</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(byte[], byte[])">encrypt</A></B>(byte[]&nbsp;plaintext,
byte[]&nbsp;key)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Encrypts data via the specified cipher key.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">encrypt</A></B>(<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>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Receives the data from the given <code>InputStream</code>, encrypts it, and sends the resulting encrypted data to the
given <code>OutputStream</code>.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>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></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#ensureSecureRandom()">ensureSecureRandom</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;byte[]</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#generateInitializationVector(boolean)">generateInitializationVector</A></B>(boolean&nbsp;streaming)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&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></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getAlgorithmName()">getAlgorithmName</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the cipher algorithm name that will be used for all encryption, decryption, and key operations (for
example, 'AES', 'Blowfish', 'RSA', 'DSA', 'TripleDES', etc).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>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></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getDefaultSecureRandom()">getDefaultSecureRandom</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getInitializationVectorSize()">getInitializationVectorSize</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the algorithm-specific size in bits of generated initialization vectors.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getKeySize()">getKeySize</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the size in bits (not bytes) of generated cipher keys.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&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></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getSecureRandom()">getSecureRandom</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns a source of randomness for encryption operations.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getStreamingBufferSize()">getStreamingBufferSize</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>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></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#getTransformationString(boolean)">getTransformationString</A></B>(boolean&nbsp;streaming)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#isGenerateInitializationVectors()">isGenerateInitializationVectors</A></B>()</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>protected &nbsp;boolean</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#isGenerateInitializationVectors(boolean)">isGenerateInitializationVectors</A></B>(boolean&nbsp;streaming)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#setGenerateInitializationVectors(boolean)">setGenerateInitializationVectors</A></B>(boolean&nbsp;generateInitializationVectors)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#setInitializationVectorSize(int)">setInitializationVectorSize</A></B>(int&nbsp;initializationVectorSize)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the algorithm-specific initialization vector size in bits (not bytes!) to be used when generating
initialization vectors.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#setKeySize(int)">setKeySize</A></B>(int&nbsp;keySize)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets the size in bits (not bytes) of generated cipher keys.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#setSecureRandom(java.security.SecureRandom)">setSecureRandom</A></B>(<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>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets a source of randomness for encryption operations.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../org/apache/shiro/crypto/JcaCipherService.html#setStreamingBufferSize(int)">setStreamingBufferSize</A></B>(int&nbsp;streamingBufferSize)</CODE>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>).</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class 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></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><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></TD>
</TR>
</TABLE>
&nbsp;
<P>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="JcaCipherService(java.lang.String)"><!-- --></A><H3>
JcaCipherService</H3>
<PRE>
protected <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.125"><B>JcaCipherService</B></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>
<DL>
<DD>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>
<P>
<DL>
<DT><B>Parameters:</B><DD><CODE>algorithmName</CODE> - the name of the cipher algorithm to use for all encryption, decryption, and key operations</DL>
</DL>
<!-- ============ METHOD DETAIL ========== -->
<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>
<A NAME="getAlgorithmName()"><!-- --></A><H3>
getAlgorithmName</H3>
<PRE>
public <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> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.142"><B>getAlgorithmName</B></A>()</PRE>
<DL>
<DD>Returns the cipher algorithm name that will be used for all encryption, decryption, and key operations (for
example, 'AES', 'Blowfish', 'RSA', 'DSA', 'TripleDES', etc).
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the cipher algorithm name that will be used for all encryption, decryption, and key operations</DL>
</DD>
</DL>
<HR>
<A NAME="getKeySize()"><!-- --></A><H3>
getKeySize</H3>
<PRE>
public int <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.151"><B>getKeySize</B></A>()</PRE>
<DL>
<DD>Returns the size in bits (not bytes) of generated cipher keys.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the size in bits (not bytes) of generated cipher keys.</DL>
</DD>
</DL>
<HR>
<A NAME="setKeySize(int)"><!-- --></A><H3>
setKeySize</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.160"><B>setKeySize</B></A>(int&nbsp;keySize)</PRE>
<DL>
<DD>Sets the size in bits (not bytes) of generated cipher keys.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>keySize</CODE> - the size in bits (not bytes) of generated cipher keys.</DL>
</DD>
</DL>
<HR>
<A NAME="isGenerateInitializationVectors()"><!-- --></A><H3>
isGenerateInitializationVectors</H3>
<PRE>
public boolean <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.164"><B>isGenerateInitializationVectors</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="setGenerateInitializationVectors(boolean)"><!-- --></A><H3>
setGenerateInitializationVectors</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.168"><B>setGenerateInitializationVectors</B></A>(boolean&nbsp;generateInitializationVectors)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getInitializationVectorSize()"><!-- --></A><H3>
getInitializationVectorSize</H3>
<PRE>
public int <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.177"><B>getInitializationVectorSize</B></A>()</PRE>
<DL>
<DD>Returns the algorithm-specific size in bits of generated initialization vectors.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the algorithm-specific size in bits of generated initialization vectors.</DL>
</DD>
</DL>
<HR>
<A NAME="setInitializationVectorSize(int)"><!-- --></A><H3>
setInitializationVectorSize</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.189"><B>setInitializationVectorSize</B></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>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>initializationVectorSize</CODE> - the size in bits (not bytes) of generated initialization vectors.
<DT><B>Throws:</B>
<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>.</DL>
</DD>
</DL>
<HR>
<A NAME="isGenerateInitializationVectors(boolean)"><!-- --></A><H3>
isGenerateInitializationVectors</H3>
<PRE>
protected boolean <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.198"><B>isGenerateInitializationVectors</B></A>(boolean&nbsp;streaming)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getStreamingBufferSize()"><!-- --></A><H3>
getStreamingBufferSize</H3>
<PRE>
public int <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.212"><B>getStreamingBufferSize</B></A>()</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><DD>the size of the internal buffer used to transfer data from one stream to another during stream
operations</DL>
</DD>
</DL>
<HR>
<A NAME="setStreamingBufferSize(int)"><!-- --></A><H3>
setStreamingBufferSize</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.226"><B>setStreamingBufferSize</B></A>(int&nbsp;streamingBufferSize)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>streamingBufferSize</CODE> - the size of the internal buffer used to transfer data from one stream to another
during stream operations</DL>
</DD>
</DL>
<HR>
<A NAME="getSecureRandom()"><!-- --></A><H3>
getSecureRandom</H3>
<PRE>
public <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> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.237"><B>getSecureRandom</B></A>()</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Returns:</B><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.</DL>
</DD>
</DL>
<HR>
<A NAME="setSecureRandom(java.security.SecureRandom)"><!-- --></A><H3>
setSecureRandom</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.248"><B>setSecureRandom</B></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>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><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.</DL>
</DD>
</DL>
<HR>
<A NAME="getDefaultSecureRandom()"><!-- --></A><H3>
getDefaultSecureRandom</H3>
<PRE>
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> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.252"><B>getDefaultSecureRandom</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="ensureSecureRandom()"><!-- --></A><H3>
ensureSecureRandom</H3>
<PRE>
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> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.262"><B>ensureSecureRandom</B></A>()</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="getTransformationString(boolean)"><!-- --></A><H3>
getTransformationString</H3>
<PRE>
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> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.280"><B>getTransformationString</B></A>(boolean&nbsp;streaming)</PRE>
<DL>
<DD>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.
<P>
<DD><DL>
</DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>streaming</CODE> - if the transformation string is going to be used for a Cipher for stream-based encryption or not.
<DT><B>Returns:</B><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.</DL>
</DD>
</DL>
<HR>
<A NAME="generateInitializationVector(boolean)"><!-- --></A><H3>
generateInitializationVector</H3>
<PRE>
protected byte[] <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.284"><B>generateInitializationVector</B></A>(boolean&nbsp;streaming)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="encrypt(byte[], byte[])"><!-- --></A><H3>
encrypt</H3>
<PRE>
public <A HREF="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.303"><B>encrypt</B></A>(byte[]&nbsp;plaintext,
byte[]&nbsp;key)</PRE>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(byte[], byte[])">CipherService</A></CODE></B></DD>
<DD>Encrypts data via the specified cipher key. Note that the key must be in a format understood by
the <code>CipherService</code> implementation.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(byte[], byte[])">encrypt</A></CODE> in interface <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>plaintext</CODE> - the data to encrypt<DD><CODE>key</CODE> - the cipher key used during encryption.
<DT><B>Returns:</B><DD>a byte source with the encrypted representation of the specified raw data.</DL>
</DD>
</DL>
<HR>
<A NAME="decrypt(byte[], byte[])"><!-- --></A><H3>
decrypt</H3>
<PRE>
public <A HREF="../../../../org/apache/shiro/util/ByteSource.html" title="interface in org.apache.shiro.util">ByteSource</A> <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.347"><B>decrypt</B></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>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(byte[], byte[])">CipherService</A></CODE></B></DD>
<DD>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.
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(byte[], byte[])">decrypt</A></CODE> in interface <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>ciphertext</CODE> - the previously encrypted data to decrypt<DD><CODE>key</CODE> - the cipher key used during decryption.
<DT><B>Returns:</B><DD>a byte source representing the original form of the specified encrypted data.
<DT><B>Throws:</B>
<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</DL>
</DD>
</DL>
<HR>
<A NAME="encrypt(java.io.InputStream, java.io.OutputStream, byte[])"><!-- --></A><H3>
encrypt</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.500"><B>encrypt</B></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>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">CipherService</A></CODE></B></DD>
<DD>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>
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#encrypt(java.io.InputStream, java.io.OutputStream, byte[])">encrypt</A></CODE> in interface <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>in</CODE> - the stream supplying the data to encrypt<DD><CODE>out</CODE> - the stream to send the encrypted data<DD><CODE>key</CODE> - the cipher key to use for encryption
<DT><B>Throws:</B>
<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.</DL>
</DD>
</DL>
<HR>
<A NAME="decrypt(java.io.InputStream, java.io.OutputStream, byte[])"><!-- --></A><H3>
decrypt</H3>
<PRE>
public void <A HREF="../../../../src-html/org/apache/shiro/crypto/JcaCipherService.html#line.526"><B>decrypt</B></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>
<DL>
<DD><B>Description copied from interface: <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">CipherService</A></CODE></B></DD>
<DD>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>
<P>
<DD><DL>
<DT><B>Specified by:</B><DD><CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html#decrypt(java.io.InputStream, java.io.OutputStream, byte[])">decrypt</A></CODE> in interface <CODE><A HREF="../../../../org/apache/shiro/crypto/CipherService.html" title="interface in org.apache.shiro.crypto">CipherService</A></CODE></DL>
</DD>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>in</CODE> - the stream supplying the data to decrypt<DD><CODE>out</CODE> - the stream to send the decrypted data<DD><CODE>key</CODE> - the cipher key to use for decryption
<DT><B>Throws:</B>
<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.</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JcaCipherService.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../org/apache/shiro/crypto/DefaultBlockCipherService.html" title="class in org.apache.shiro.crypto"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../org/apache/shiro/crypto/OperationMode.html" title="enum in org.apache.shiro.crypto"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../../index.html?org/apache/shiro/crypto/JcaCipherService.html" target="_top"><B>FRAMES</B></A> &nbsp;
&nbsp;<A HREF="JcaCipherService.html" target="_top"><B>NO FRAMES</B></A> &nbsp;
&nbsp;<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<HR>
Copyright &#169; 2004-2014 <a href="http://www.apache.org/">The Apache Software Foundation</a>. All Rights Reserved.
</BODY>
</HTML>