more html to md

Project: http://git-wip-us.apache.org/repos/asf/shiro-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro-site/commit/f37b5848
Tree: http://git-wip-us.apache.org/repos/asf/shiro-site/tree/f37b5848
Diff: http://git-wip-us.apache.org/repos/asf/shiro-site/diff/f37b5848

Branch: refs/heads/master
Commit: f37b58488c5818f71b7994744856fe3d0caa2b30
Parents: a2ce402
Author: Brian Demers <[email protected]>
Authored: Sun Oct 23 23:28:24 2016 -0400
Committer: Brian Demers <[email protected]>
Committed: Sun Oct 23 23:28:24 2016 -0400

----------------------------------------------------------------------
 java-authentication-guide.html.vtl | 168 -----------
 java-authentication-guide.md.vtl   | 169 +++++++++++
 java-authorization-guide.html.vtl  | 234 ---------------
 java-authorization-guide.md.vtl    | 255 ++++++++++++++++
 java-cryptography-guide.html.vtl   |  95 ------
 java-cryptography-guide.md.vtl     | 109 +++++++
 realm.html.vtl                     | 218 --------------
 realm.md.vtl                       | 246 +++++++++++++++
 subject.html.vtl                   | 355 ----------------------
 subject.md.vtl                     | 328 ++++++++++++++++++++
 testing.html.vtl                   | 240 ---------------
 testing.md.vtl                     | 253 ++++++++++++++++
 tutorial.html.vtl                  | 513 --------------------------------
 tutorial.md.vtl                    | 492 ++++++++++++++++++++++++++++++
 14 files changed, 1852 insertions(+), 1823 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-authentication-guide.html.vtl
----------------------------------------------------------------------
diff --git a/java-authentication-guide.html.vtl 
b/java-authentication-guide.html.vtl
deleted file mode 100644
index 9be7231..0000000
--- a/java-authentication-guide.html.vtl
+++ /dev/null
@@ -1,168 +0,0 @@
-<h1><a 
name="JavaAuthenticationGuide-JavaAuthenticationGuidewithApacheShiro"></a>Java 
Authentication Guide with Apache Shiro</h1>
-
-<p><br clear="none" class="atl-forced-newline">
-Authentication is the process of identity verification-- you are trying to 
prove a user is who they say they are. To do so, a user needs to provide some 
sort of proof of identity that your system understands and trust.</p>
-
-<p>The goal of this guide is to walk you through how Authentication in Java is 
performed in Shiro. If you haven't already please take moment and go through 
Shiro's <a href="10-minute-tutorial.html" title="10 Minute Tutorial">10 Minute 
Tutorial</a> so that you get a basic understanding of how to work with 
Shiro.</p>
-
-<h2><a name="JavaAuthenticationGuide-Terminologyyou%27llneed"></a>Terminology 
you'll need</h2>
-
-<table align="right" width="275" style="margin-left: 20px; margin-bottom: 
20px; border-style: solid; border-width: 2px; border-color: navy" 
cellpadding="10px">
-
-<tr>
-<td>
-<div id="border">
-  <h2>Related Content</h2>
-       
-  <h3><a href="authentication-features.html">Authentication Features</a></h3>
-  <p>Quick overview of easy, subject-based authentication in Shiro. </br><span 
style="font-size:11"><a href="authentication-features.html">Read More 
&gt;&gt;</a></span></p>
-       
-  <h3><a href="authentication.html">Authentication Docs</a></h3>
-  <p>Full documentation on Apache Shiro's Authentication functionality. 
</br><span style="font-size:11"><a href="authentication.html">Read More 
&gt;&gt;</a></span></p>
-       
-       <h3><a href="10-minute-tutorial.html">10-Minute Shiro Tutorial</a></h3>
-  <p>Try Apache Shiro for yourself in under 10 minutes. </br><span 
style="font-size:11"><a href="10-minute-tutorial.html">Read More 
&gt;&gt;</a></span></p>
-       
-       <h3><a href="webapp-tutorial.html">Web App Tutorial</a></h3>
-  <p>Step-by-step tutorial for securing a web application with Shiro. 
</br><span style="font-size:11"><a href="webapp-tutorial.html">Read More 
&gt;&gt;</a></span></p>
-
-</div>
-</td>
-</tr>
-</table>
-
-<ul><li><b>Subject</b> - Security specific user 'view' of an application user. 
 It can be a human being, a third-party process, a server connecting to you 
application application, or even a cron job.  Basically, it is anything or 
anyone communicating with your application.</li></ul>
-
-
-<ul><li><b>Principals</b> - A subjects identifying attributes.  First name, 
last name, social security number, username</li></ul>
-
-
-<ul><li><b>Credentials</b> - secret data that are used to verify identities.  
Passwords, Biometric data, x509 certificates,</li></ul>
-
-
-<ul><li><b>Realms</b> - Security specific DAO, data access object, software 
component that talkts to a backend data source. If you have usernames and 
password in LDAP, then you would have an LDAP Realm that would communicate with 
LDAP.  The idea is that you would use a realm per back-end data source and 
Shiro would know how to coordinate with these realms together to do what you 
have to do.</li></ul>
-
-
-<h2><a name="JavaAuthenticationGuide-HowtoAuthenticateinJavawithShiro"></a>How 
to Authenticate in Java with Shiro</h2>
-
-<p>In Shiro's framework, and most every other framework for that matter, the 
Java authentication process can be broken up into three distinct steps.</p>
-
-<h3><a name="JavaAuthenticationGuide-Steps"></a>Steps</h3>
-
-<ol><li>Collect the subject's principals and credentials</li><li>Submit the 
principals and credentials to an authentication system.</li><li>Allow access, 
retry authentication, or block access</li></ol>
-
-
-<p>Here is some code on how you do this in Shiro Specifically.</p>
-
-<h3><a 
name="JavaAuthenticationGuide-Step1Collectthesubject%27sprincipalsandcredentials"></a>Step
 1 - Collect the subject's principals and credentials</h3>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//Example using most common scenario:
-</span><span class="code-comment">//<span class="code-object">String</span> 
username and password.  Acquire in
-</span><span class="code-comment">//system-specific manner (HTTP request, GUI, 
etc)
-</span>
-UsernamePasswordToken token =
- <span class="code-keyword">new</span> UsernamePasswordToken( username, 
password );
-
-<span class="code-comment">//&#8221;Remember Me&#8221; built-in, just <span 
class="code-keyword">do</span> <span class="code-keyword">this</span>:
-</span>token.setRememberMe(<span class="code-keyword">true</span>);
-
-</pre>
-</div></div>
-
-<p>In this particular case, we&#8217;re using a class called <a 
class="external-link" 
href="static/current/apidocs/org/apache/shiro/authc/UsernamePasswordToken.html">UsernamePasswordToken</a>.
  It is the most common authentication token used in the framework.</p>
-
-<p>We use this token to bundle the username and password we acquired in 
someway in our Java application.  Maybe they were submitted via a user web 
form, an HTTP header, or a command line. In Shiro, it does not matter how you 
acquire them-- it is protocol agnostic.</p>
-
-<p>In this example, we have decided that we want the application to remember 
users when they return.  So once the token is created, we use Shiro's built-in 
"Remember-me" feature by setting it to true on the token.  This is done using 
the token's <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/authc/UsernamePasswordToken.html#[[#]]#setRememberMe(boolean)">setRememberMe()</a></tt>
 method</p>
-
-<h3><a 
name="JavaAuthenticationGuide-Step2Submittheprincipalsandcredentialstoanauthenticationsystem."></a>Step
 2 - Submit the principals and credentials to an authentication system.</h3>
-<p>So we&#8217;ve collected the information in a token and set it to remember 
returning users. The next step is in the Authentication process is to submit 
the token to an authentication system. Your authentication system is 
represented in Shiro by security-specific DAOs, that are referred to as <a 
class="external-link" href="static/current/apidocs/">Realms</a>.  For more 
information on realms please check out the <a class="external-link" 
href="realm.html">Shiro Realm Guide</a>.</p>
-
-<p>In Shiro we try to make this part as quick and easy as humanly possible.  
We have it down to one line of Java code!</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//With most of Shiro, you'll always want to make 
sure you're working with the currently executing user, referred to as the 
subject
-</span>Subject currentUser = SecurityUtils.getSubject();
-
-<span class="code-comment">//Authenticate the subject by passing
-</span><span class="code-comment">//the user name and password token
-</span><span class="code-comment">//into the login method
-</span>currentUser.login(token);
-</pre>
-</div></div>
-
-<p>First, we need to acquire the currently executing user, referred to as the 
subject.   A subject is just a security specific view of the user----it can be 
a human, a process, cron job, doesn&\#8217;t matter. In Shiro, there is always 
a subject instance available to the currently executing thread.  The concept of 
a subject is core to Shiro and most of the framework is centered around working 
with subjects. In this example, we will name this instance of subject 
currentUser.</p>
-
-<p>To acquire the subject, we use the <a class="external-link" 
href="static/current/apidocs/org/apache/shiro/SecurityUtils.html">SecurityUtils</a>
 class which is also a core pat of Shiro's API.  It will acquire the currently 
executing user via the <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/SecurityUtils.html#[[#]]#getSubject()">getsubject()</a></tt>
 method call.  And we get back a subject instance that is representing who the 
current user is who is interacting with the system.  At this point in the 
example, the subject currentUser is anonymous.  There is no identity associated 
with them.</p>
-
-<p>Now with the user representation in hand, we authenticate them by just 
calling the <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#login(org.apache.shiro.authc.AuthenticationToken))">login()</a></tt>
 method and submit the token we just constructed a second ago.</p>
-
-<h3><a 
name="JavaAuthenticationGuide-Step3Allowaccess%2Cretryauthentication%2Corblockaccess"></a>Step
 3 - Allow access, retry authentication, or block access</h3>
-<p>Again really, really easy, single method call.  If the <tt>login()</tt> 
method call is successful, then the user is logged in and associated with a 
user account or identity.  From here, the user can go about using your 
application and retain their identity through their session or longer since we 
have set the "Remember Me" in our example.</p>
-
-<p>But what happens if something fails in the authentication attempt?  What if 
they give you the wrong password or they accessed the system too many times, 
maybe their account is locked?  In this case, Shiro will throw an exception. 
This is where Shiro's rich exception hierarchy comes into play.</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-keyword">try</span> {
-    currentUser.login(token);
-} <span class="code-keyword">catch</span> ( UnknownAccountException uae ) { ...
-} <span class="code-keyword">catch</span> ( IncorrectCredentialsException ice 
) { ...
-} <span class="code-keyword">catch</span> ( LockedAccountException lae ) { ...
-} <span class="code-keyword">catch</span> ( ExcessiveAttemptsException eae ) { 
...
-} ... <span class="code-keyword">catch</span> your own ...
-} <span class="code-keyword">catch</span> ( AuthenticationException ae ) {
-    <span class="code-comment">//unexpected error?
-</span>}
-<span class="code-comment">//No problems, show authenticated view&#8230;</span>
-</pre>
-</div></div>
-
-<p>You can take that method call and wrap it in a try/catch block and you can 
catch all sort of exceptions if you want to handle them and react accordingly.  
In addition to a rich set of exceptions that Shiro offers, you can create your 
own if you need custom functionality.  For more information, follow this link 
documentation on <a class="external-link" 
href="static/current/apidocs/org/apache/shiro/authc/AuthenticationException.html">AuthenticationException</a>.</p>
-
-#tip('Security Tip', 'Security best practice is to give generic login failure 
messages to users because you do not want to aid an attacker trying to break 
into your system.')
-
-<h2><a name="JavaAuthenticationGuide-%22RememberMe%22Support"></a>"Remember 
Me" Support</h2>
-
-<p>As shown in the example above, Shiro supports the notion of "remember me" 
in adition to the normal login process. &#160;</p>
-
-<p>In Shiro, the Subject object supports two methods : <tt><a 
class="external-link" 
href="static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isRemembered()">isRemembered()</a></tt>
 and <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isAuthenticated()">isAuthenticated()</a></tt>.</p>
-
-<p>A "remembered" subject has an identity (it is not anonymous) and their 
identifying attributes,referred to as principals, are remembered from a 
successful authentication during a previous session.</p>
-
-<p>An authenticated subject has proved their identity <em>during their current 
session</em>.</p>
-
-#danger('Warning', 'If a subject is remembered, it DOES NOT mean they are 
authenticated.')
-
-<h3><a name="JavaAuthenticationGuide-RememberedvsAuthenticated"></a>Remembered 
vs Authenticated</h3>
-<p>In shiro it is very important to note that a remembered subject is not an 
authenticated subject. A check against <tt>isAuthenticated()</tt> is a much 
more strict check because authentication is the process of proving you are who 
you say you are. When a user is only remembered, the remembered identity gives 
the system an idea who that user probably is, but in reality, has no way of 
absolutely guaranteeing if the remembered Subject represents the user currently 
using the application. Once the subject is authenticated, they are no longer 
considered only remembered because their identity would have been verified 
during the current session.</p>
-
-<p>So although many parts of the application can still perform user-specific 
logic based on the remembered principals, such as customized views, it should 
never perform highly-sensitive operations until the user has legitimately 
verified their identity by executing a successful authentication attempt.</p>
-
-<p>For example, a check to see if a subject can access financial information 
should almost always depend on <tt>isAuthenticated()</tt>, not 
<tt>isRemembered()</tt>, to guarantee a verified identity.</p>
-
-<p>He is a scenario to help illustrate why the the distinction between 
isAuthenticated and isRemembered is important.</p>
-
-<p>Let's say you're using Amazon.com. You log in and you add some books to 
your shopping cart.  A day goes by.  Of course your user session has expired 
and you've been logged out. But Amazon "remembers" you, greets you by name, and 
is still giving you personalized book recommendations.  To Amazon, 
<tt>isRemembered()</tt> would return <tt>TRUE</tt>.  What happens if you try to 
use one of the credit cards on file or change your account information?  While 
Amazon "remembers" you, <tt>isRemembered() = TRUE</tt>, it is not certain that 
you are in fact you, <tt>isAuthenticated()=FALSE</tt>.  So before you can 
perform a sensitive action Amazon needs to verify your identity by forcing an 
authentication process which it does through a login screen.  After the login, 
your identity has been verified and <tt>isAuthenticated()=TRUE</tt>.</p>
-
-<p>This scenario happens very often over the web so the functionality is built 
into Shiro helping you easily make the distinction yourself.</p>
-
-<h2><a name="JavaAuthenticationGuide-LoggingOut"></a>Logging Out</h2>
-<p>Finally, when the user is done using the application, they can log out.  
And in Shiro, we make logging out quick and easy with a single method call.</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-currentUser.logout(); <span class="code-comment">//removes all identifying 
information and invalidates their session too.</span>
-</pre>
-</div></div>
-
-<p>When you log out in Shiro it will close out the user session and removes 
any associated identity from the subject instance.  If you're using RememberMe 
in a web environment, then <tt>.logout()</tt> will, by default, also delete the 
RememberMe cookie from the browser.</p>
-
-<h2><a name="JavaAuthenticationGuide-Lendahandwithdocumentation"></a>Lend a 
hand with documentation </h2>
-
-<p>While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time.  If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro. </p>
-
-<p>The easiest way to contribute your documentation is to send it to the <a 
class="external-link" href="http://shiro-user.582556.n2.nabble.com/"; 
rel="nofollow">User Forum</a> or the <a href="mailing-lists.html" 
title="Mailing Lists">User Mailing List</a>.</p>

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-authentication-guide.md.vtl
----------------------------------------------------------------------
diff --git a/java-authentication-guide.md.vtl b/java-authentication-guide.md.vtl
new file mode 100644
index 0000000..8d9a539
--- /dev/null
+++ b/java-authentication-guide.md.vtl
@@ -0,0 +1,169 @@
+<a name="JavaAuthenticationGuide-JavaAuthenticationGuidewithApacheShiro"></a>
+Java Authentication Guide with Apache Shiro
+===========================================
+
+Authentication is the process of identity verification-- you are trying to 
prove a user is who they say they are. To do so, a user needs to provide some 
sort of proof of identity that your system understands and trust.
+
+The goal of this guide is to walk you through how Authentication in Java is 
performed in Shiro. If you haven't already please take moment and go through 
Shiro's [10 Minute Tutorial](10-minute-tutorial.html "10 Minute Tutorial") so 
that you get a basic understanding of how to work with Shiro.
+
+<a name="JavaAuthenticationGuide-Terminologyyou%27llneed"></a>
+Terminology you'll need
+-----------------------
+
+<table align="right" width="275" style="margin-left: 20px; margin-bottom: 
20px; border-style: solid; border-width: 2px; border-color: navy" 
cellpadding="10px"><tr><td>
+<div id="border">
+  <h2>Related Content</h2>
+
+  <h3><a href="authentication-features.html">Authentication Features</a></h3>
+  <p>Quick overview of easy, subject-based authentication in Shiro. </br><span 
style="font-size:11"><a href="authentication-features.html">Read More 
&gt;&gt;</a></span></p>
+
+  <h3><a href="authentication.html">Authentication Docs</a></h3>
+  <p>Full documentation on Apache Shiro's Authentication functionality. 
</br><span style="font-size:11"><a href="authentication.html">Read More 
&gt;&gt;</a></span></p>
+
+       <h3><a href="10-minute-tutorial.html">10-Minute Shiro Tutorial</a></h3>
+  <p>Try Apache Shiro for yourself in under 10 minutes. </br><span 
style="font-size:11"><a href="10-minute-tutorial.html">Read More 
&gt;&gt;</a></span></p>
+
+       <h3><a href="webapp-tutorial.html">Web App Tutorial</a></h3>
+  <p>Step-by-step tutorial for securing a web application with Shiro. 
</br><span style="font-size:11"><a href="webapp-tutorial.html">Read More 
&gt;&gt;</a></span></p>
+
+</div>
+</td></tr></table>
+
+*   **Subject** - Security specific user 'view' of an application user. It can 
be a human being, a third-party process, a server connecting to you application 
application, or even a cron job. Basically, it is anything or anyone 
communicating with your application.
+
+*   **Principals** - A subjects identifying attributes. First name, last name, 
social security number, username
+
+*   **Credentials** - secret data that are used to verify identities. 
Passwords, Biometric data, x509 certificates,
+
+*   **Realms** - Security specific DAO, data access object, software component 
that talkts to a backend data source. If you have usernames and password in 
LDAP, then you would have an LDAP Realm that would communicate with LDAP. The 
idea is that you would use a realm per back-end data source and Shiro would 
know how to coordinate with these realms together to do what you have to do.
+
+<a name="JavaAuthenticationGuide-HowtoAuthenticateinJavawithShiro"></a>
+#[[##How to Authenticate in Java with Shiro]]#
+
+In Shiro's framework, and most every other framework for that matter, the Java 
authentication process can be broken up into three distinct steps.
+
+<a name="JavaAuthenticationGuide-Steps"></a>
+#[[###Steps]]#
+
+1.  Collect the subject's principals and credentials
+2.  Submit the principals and credentials to an authentication system.
+3.  Allow access, retry authentication, or block access
+
+Here is some code on how you do this in Shiro Specifically.
+
+<a 
name="JavaAuthenticationGuide-Step1Collectthesubject%27sprincipalsandcredentials"></a>
+#[[###Step 1 - Collect the subject's principals and credentials]]#
+
+``` java
+//Example using most common scenario: 
+//String username and password.  Acquire in 
+//system-specific manner (HTTP request, GUI, etc)
+UsernamePasswordToken token = new UsernamePasswordToken( username, password );
+
+//”Remember Me” built-in, just do this: 
+token.setRememberMe(true);
+```
+
+In this particular case, we’re using a class called 
[UsernamePasswordToken](static/current/apidocs/org/apache/shiro/authc/UsernamePasswordToken.html).
 It is the most common authentication token used in the framework.
+
+We use this token to bundle the username and password we acquired in someway 
in our Java application. Maybe they were submitted via a user web form, an HTTP 
header, or a command line. In Shiro, it does not matter how you acquire them-- 
it is protocol agnostic.
+
+In this example, we have decided that we want the application to remember 
users when they return. So once the token is created, we use Shiro's built-in 
"Remember-me" feature by setting it to true on the token. This is done using 
the token's 
[`setRememberMe()`](static/current/apidocs/org/apache/shiro/authc/UsernamePasswordToken.html#[[#]]#setRememberMe-boolean-)
 method
+
+<a 
name="JavaAuthenticationGuide-Step2Submittheprincipalsandcredentialstoanauthenticationsystem."></a>
+#[[###Step 2 - Submit the principals and credentials to an authentication 
system.]]#
+
+So we’ve collected the information in a token and set it to remember 
returning users. The next step is in the Authentication process is to submit 
the token to an authentication system. Your authentication system is 
represented in Shiro by security-specific DAOs, that are referred to as 
[Realms](static/current/apidocs/). For more information on realms please check 
out the [Shiro Realm Guide](realm.html).
+
+In Shiro we try to make this part as quick and easy as humanly possible. We 
have it down to one line of Java code!
+
+``` java
+//With most of Shiro, you'll always want to make sure you're working with the 
currently 
+//executing user, referred to as the subject 
+Subject currentUser = SecurityUtils.getSubject();
+
+//Authenticate the subject by passing 
+//the user name and password token 
+//into the login method 
+currentUser.login(token);
+```
+
+First, we need to acquire the currently executing user, referred to as the 
subject. A subject is just a security specific view of the user----it can be a 
human, a process, cron job, doesn&\#8217;t matter. In Shiro, there is always a 
subject instance available to the currently executing thread. The concept of a 
subject is core to Shiro and most of the framework is centered around working 
with subjects. In this example, we will name this instance of subject 
currentUser.
+
+To acquire the subject, we use the 
[SecurityUtils](static/current/apidocs/org/apache/shiro/SecurityUtils.html) 
class which is also a core pat of Shiro's API. It will acquire the currently 
executing user via the 
[`getsubject()`](static/current/apidocs/org/apache/shiro/SecurityUtils.html#[[#]]#getSubject--)
 method call. And we get back a subject instance that is representing who the 
current user is who is interacting with the system. At this point in the 
example, the subject currentUser is anonymous. There is no identity associated 
with them.
+
+Now with the user representation in hand, we authenticate them by just calling 
the 
[`login()`](static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#login-org.apache.shiro.authc.AuthenticationToken-))
 method and submit the token we just constructed a second ago.
+
+<a 
name="JavaAuthenticationGuide-Step3Allowaccess%2Cretryauthentication%2Corblockaccess"></a>
+#[[###Step 3 - Allow access, retry authentication, or block access]]#
+
+Again really, really easy, single method call. If the `login()` method call is 
successful, then the user is logged in and associated with a user account or 
identity. From here, the user can go about using your application and retain 
their identity through their session or longer since we have set the "Remember 
Me" in our example.
+
+But what happens if something fails in the authentication attempt? What if 
they give you the wrong password or they accessed the system too many times, 
maybe their account is locked? In this case, Shiro will throw an exception. 
This is where Shiro's rich exception hierarchy comes into play.
+
+``` java
+try {
+    currentUser.login(token);
+} catch  ( UnknownAccountException uae ) { ...
+} catch  ( IncorrectCredentialsException ice ) { ...
+} catch  ( LockedAccountException lae ) { ...
+} catch  ( ExcessiveAttemptsException eae ) { ...
+} ...  your own ...
+} catch ( AuthenticationException ae ) {
+    //unexpected error?
+}
+//No problems, show authenticated view…
+```
+
+You can take that method call and wrap it in a try/catch block and you can 
catch all sort of exceptions if you want to handle them and react accordingly. 
In addition to a rich set of exceptions that Shiro offers, you can create your 
own if you need custom functionality. For more information, follow this link 
documentation on 
[AuthenticationException](static/current/apidocs/org/apache/shiro/authc/AuthenticationException.html).
+
+#tip('Security Tip', 'Security best practice is to give generic login failure 
messages to users because you do not want to aid an attacker trying to break 
into your system.')
+
+<a name="JavaAuthenticationGuide-%22RememberMe%22Support"></a>
+"Remember Me" Support
+---------------------
+
+As shown in the example above, Shiro supports the notion of "remember me" in 
adition to the normal login process.  
+
+In Shiro, the Subject object supports two methods : 
[`isRemembered()`](static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isRemembered--)
 and 
[`isAuthenticated()`](static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isAuthenticated--).
+
+A "remembered" subject has an identity (it is not anonymous) and their 
identifying attributes,referred to as principals, are remembered from a 
successful authentication during a previous session.
+
+An authenticated subject has proved their identity _during their current 
session_.
+
+#danger('Warning', 'If a subject is remembered, it DOES NOT mean they are 
authenticated.')
+
+<a name="JavaAuthenticationGuide-RememberedvsAuthenticated"></a>
+#[[###Remembered vs Authenticated]]#
+
+In shiro it is very important to note that a remembered subject is not an 
authenticated subject. A check against `isAuthenticated()` is a much more 
strict check because authentication is the process of proving you are who you 
say you are. When a user is only remembered, the remembered identity gives the 
system an idea who that user probably is, but in reality, has no way of 
absolutely guaranteeing if the remembered Subject represents the user currently 
using the application. Once the subject is authenticated, they are no longer 
considered only remembered because their identity would have been verified 
during the current session.
+
+So although many parts of the application can still perform user-specific 
logic based on the remembered principals, such as customized views, it should 
never perform highly-sensitive operations until the user has legitimately 
verified their identity by executing a successful authentication attempt.
+
+For example, a check to see if a subject can access financial information 
should almost always depend on `isAuthenticated()`, not `isRemembered()`, to 
guarantee a verified identity.
+
+He is a scenario to help illustrate why the the distinction between 
isAuthenticated and isRemembered is important.
+
+Let's say you're using Amazon.com. You log in and you add some books to your 
shopping cart. A day goes by. Of course your user session has expired and 
you've been logged out. But Amazon "remembers" you, greets you by name, and is 
still giving you personalized book recommendations. To Amazon, `isRemembered()` 
would return `TRUE`. What happens if you try to use one of the credit cards on 
file or change your account information? While Amazon "remembers" you, 
`isRemembered() = TRUE`, it is not certain that you are in fact you, 
`isAuthenticated()=FALSE`. So before you can perform a sensitive action Amazon 
needs to verify your identity by forcing an authentication process which it 
does through a login screen. After the login, your identity has been verified 
and `isAuthenticated()=TRUE`.
+
+This scenario happens very often over the web so the functionality is built 
into Shiro helping you easily make the distinction yourself.
+
+<a name="JavaAuthenticationGuide-LoggingOut"></a>
+Logging Out
+-----------
+
+Finally, when the user is done using the application, they can log out. And in 
Shiro, we make logging out quick and easy with a single method call.
+
+``` java
+currentUser.logout(); //removes all identifying information and invalidates 
their session too.
+```
+
+When you log out in Shiro it will close out the user session and removes any 
associated identity from the subject instance. If you're using RememberMe in a 
web environment, then `.logout()` will, by default, also delete the RememberMe 
cookie from the browser.
+
+<a name="JavaAuthenticationGuide-Lendahandwithdocumentation"></a>
+Lend a hand with documentation
+------------------------------
+
+While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time. If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro.
+
+The easiest way to contribute your documentation is to send it to the [User 
Forum](http://shiro-user.582556.n2.nabble.com/) or the [User Mailing 
List](mailing-lists.html "Mailing Lists").
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-authorization-guide.html.vtl
----------------------------------------------------------------------
diff --git a/java-authorization-guide.html.vtl 
b/java-authorization-guide.html.vtl
deleted file mode 100644
index da00351..0000000
--- a/java-authorization-guide.html.vtl
+++ /dev/null
@@ -1,234 +0,0 @@
-<h1><a 
name="JavaAuthorizationGuide-JavaAuthorizationGuidewithApacheShiro"></a>Java 
Authorization Guide with Apache Shiro</h1>
-
-<p><br clear="none" class="atl-forced-newline">
-Authorization, or access control, is the function of specifying access rights 
to resources.  In other words, <em>who</em> has access to <em>what</em>.</p>
-
-<p>Examples of authorization checks are: Is the user allowed to look at this 
webpage, edit this data, view this button, or print to this printer?  Those are 
all decisions determining what a user has access to.</p>
-
-<h2><a name="JavaAuthorizationGuide-ElementsofAuthorization"></a>Elements of 
Authorization</h2>
-<p>Authorization has three core elements that we reference quite a bit in 
Shiro-- permissions, roles, and users.  </p>
-
-<h3><a name="JavaAuthorizationGuide-PermissionsDefined"></a>Permissions 
Defined</h3>
-
-<table align="right" width="275" style="margin-left: 20px; margin-bottom: 
20px; border-style: solid; border-width: 2px; border-color: navy" 
cellpadding="10px">
-
-<tr>
-<td>
-<div id="border">
-  <h2>Related Content</h2>
-       
-  <h3><a href="authorization-features.html">Authorization Features</a></h3>
-  <p>Quick overview of permissions, roles, and users in Shiro. </br><span 
style="font-size:11"><a href="authorization-features.html">Read More 
&gt;&gt;</a></span></p>
-       
-  <h3><a href="authorization.html">Authorization Docs</a></h3>
-  <p>Full documentation on Apache Shiro's Authorization functionality. 
</br><span style="font-size:11"><a href="authorization.html">Read More 
&gt;&gt;</a></span></p>
-       
-  <h3><a href="get-started.html">Getting Started</a></h3>
-  <p>Resources, guides and tutorials for new Shiro users. </br><span 
style="font-size:11"><a href="get-started.html">Read More 
&gt;&gt;</a></span></p> 
-       
-  <h3><a href="10-minute-tutorial.html">10-Minute Shiro Tutorial</a></h3>
-  <p>Try Apache Shiro for yourself in under 10 minutes. </br><span 
style="font-size:11"><a href="10-minute-tutorial.html">Read More 
&gt;&gt;</a></span></p>
-       
-  <h3><a href="webapp-tutorial.html">Web App Tutorial</a></h3>
-  <p>Step-by-step tutorial for securing a web application with Shiro. 
</br><span style="font-size:11"><a href="webapp-tutorial.html">Read More 
&gt;&gt;</a></span></p>
-       
-</div>
-</td>
-</tr>
-</table>
-
-<p>Permissions are the most atomic level of a security policy and they are 
statements of functionality. Permissions represent what can be done in your 
application.  A well formed permission describes a resource types and what 
actions are possible when you interact with those resources.    Can you 
<em>open</em> a <em>door</em>?  Can you <em>read</em> a <em>file</em>? Can you 
<em>delete</em> a <em>customer record</em>? Can you <em>push</em> a 
<em>button</em>? </p>
-
-<p>Common actions for data-related resources are create, read, update, and 
delete, commonly referred to as CRUD.</p>
-
-<p>It is important to understand that permissions do not have knowledge of 
<em>who</em> can perform the actions-- they are just statements of 
<em>what</em> actions can be performed.</p>
-
-<h4><a name="JavaAuthorizationGuide-Levelsofpermissiongranularity"></a>Levels 
of permission granularity</h4>
-<p>The permissions above all specify an actions (open, read, delete, etc) on a 
resource (door, file, customer record, etc).  In Shiro, you can define a 
permission to any depth you like.  Here are a few common permission levels in 
order of granularity.</p>
-
-<ul><li>Resource Level - This is the broadest and easiest to build.  A user 
can edit customer records or open doors.  The resource is specified but not a 
specific instance of that resource.</li><li>Instance Level - The permission 
specifies the instance of a resource.  A user can edit the customer record for 
IBM or open the kitchen door.</li><li>Attribute Level - The permission now 
specifies an attribute of an instance or resource.  A user can edit the address 
on the IBM customer record.</li></ul>
-
-
-<p>For more information on Permissions please check out the <a 
href="permissions.html" title="Permissions">Permissions Documentation</a></p>
-
-<h3><a name="JavaAuthorizationGuide-RolesDefined"></a>Roles Defined</h3>
-<p>In the context of Authorization, Roles are effectively a collection of 
permissions used to simplify the management of permissions and users.  So users 
can be assigned roles instead of being assigned permissions directly, which can 
get complicated with larger user bases and more complex applications.  So, for 
example, a bank application might have an <em>administrator</em> role or a 
<em>bank teller</em> role.</p>
-
-<p>There are two types of roles that you need to be aware of and Shiro will 
support both.</p>
-
-<h4><a name="JavaAuthorizationGuide-ImplicitRoles"></a>Implicit Roles</h4>
-<p>Most people view roles as what we define as an implicit role where your 
application <em>implies</em> a set of permissions because a user has a 
particular role as opposed to the role explicitly being assigned permissions or 
your application checking for those permissions.  Role checks in code are 
generally a reflection of an implicit role.  You can view patient data because 
you have the <em>administrator</em> role.  You can create an account because 
you have the <em>bank teller</em> role.  The fact that these names exist does 
not have a correlation to what the software can actually do.  Most people use 
roles in this manner.  It is easiest but it can create a lot of maintenance and 
management problems for all the but the simplest application.</p>
-
-<h4><a name="JavaAuthorizationGuide-ExplicitRoles"></a>Explicit Roles</h4>
-<p>An explicit role has permissions <em>explicitly</em> assigned to it and 
therefore is an <em>explicit</em> collection of permissions.  Permission checks 
in code are a reflection of an explicit role.  You can view patient data 
because because you have the <em>view patient data</em> permission as part of 
your <em>administrator</em> role.  You can create an account because you have 
the <em>create account</em> permission as part of your <em>bank teller</em> 
role.  You can perform these actions, not because of some implicit role name 
based on a string but because the corresponding permission was explicitly 
assigned to your role.</p>
-
-<p>The big benefits of explicit roles are easier manageability and lower 
maintenance of your application.  If you ever need to add, remove, or change a 
role, you can do so without touching your source code.  And in Shiro, you'll 
also be able to dynamically add, remove, or change roles at runtime and your 
authorization checks will always have up to date values.  This means you won't 
have to force users to log out and log back in order to get their new 
permissions.</p>
-
-<h3><a name="JavaAuthorizationGuide-UsersDefined"></a>Users Defined</h3>
-<p>A user is the "who" of an application.  In Shiro, though, the concept of a 
user is really the <a href="subject.html" title="Subject">Subject</a> instance. 
 We use word Subject instead of user because user usually implies a human being 
and in Shiro a Subject can be anything interacting with your application-- 
whether it be a human or a service.  </p>
-
-<p>Users are allowed to perform certain actions in your application through 
their association with roles or direct permissions.  So you are able to open a 
customer record because you've been assigned the <em>open customer record</em> 
permission, either through a role you've been assigned or through a direct 
permission assignment.</p>
-
-<p>For more information on Users, aka Subjects, please check out the <a 
href="subject.html" title="Subject">Subject Documentation</a>.</p>
-
-#info('Note', 'Ultimately, your <a href="realm.html" title="Realm">Realm</a> 
implementation is what communicates with your data source (RDBMS, LDAP, etc). 
So your realm is what will tell Shiro whether or not roles or permissions 
exist. You have full control over how your authorization model works.')
-
-<h2><a 
name="JavaAuthorizationGuide-HowtoperformAuthorizationinJavawithShiro"></a>How 
to perform Authorization in Java with Shiro</h2>
-<p>Authorization in Shiro can be handled in four ways.</p>
-
-<ul><li>Programmatically - You can perform authorization checks in your java 
code with structures like <tt>if</tt> and <tt>else</tt> blocks.</li><li>JDK 
annotations - You can attach an authorization annotation to your Java 
methods</li><li>JSP/GSP TagLibs - You can control jsp or gsp page output based 
on roles and permissions</li></ul>
-
-
-<h3><a 
name="JavaAuthorizationGuide-ProgrammaticAuthorization"></a>Programmatic 
Authorization</h3>
-<p>Checking for permissions and roles, programmatically in your Java code is 
the traditional way of handling authorization.  Here's how you can perform a 
permission check or role check in Shiro.</p>
-
-<h4><a name="JavaAuthorizationGuide-RoleCheck"></a>Role Check</h4>
-<p>This is an example of how you do a role check programmatically in your 
application.  We want to check if a user has the <em>administrator</em> role 
and if they do, then we'll show a special button, otherwise we won't show 
it.</p>
-
-<p>First we get access to the current user, the <a href="subject.html" 
title="Subject">Subject</a>. Then we pass the <em>adminstrator</em> to the 
Subject's <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#hasRole(java.lang.String)">.hasRole()</a></tt>
 method.  It will return <tt>TRUE</tt> or <tt>FALSE</tt>.  </p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//get the current Subject
-</span>Subject currentUser =
-    SecurityUtils.getSubject();
-
-<span class="code-keyword">if</span> 
(currentUser.hasRole(&#8220;administrator&#8221;)) {
-    <span class="code-comment">//show a special button&#8207;
-</span>} <span class="code-keyword">else</span> {
-    <span class="code-comment">//don&#8217;t show the button?)&#8207;
-</span>}
-</pre>
-</div></div>
-
-<p>Now a role based check is quick and easy to implement but it has a major 
drawback. It is implicit.</p>
-
-<p>What if you just want to add, remove, or redefine a role later?  You'll 
have to crack open your source code and change all your role checks to reflect 
the change in your security model. You'll have to shut down the application, 
crack open the code, test it, and then restart it everytime.  </p>
-
-<p>In very simple applications this is probably good enough but for larger 
apps this can be a major problem throughout the life of your application and 
drive a large maintenance cost for your software.  </p>
-
-<h4><a name="JavaAuthorizationGuide-PermissionCheck"></a>Permission Check</h4>
-<p>This is an example of how you do security checks by permission. We want to 
check if a user has permission to print to laserjet3000n and if they do, then 
we'll show a print button, otherwise we won't show it. This is an example of an 
instance level permission or instance level authorization.</p>
-
-<p>Again, first you get access to the current user, the <a href="subject.html" 
title="Subject">Subject</a>.  Then you construct a <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/authz/Permission.html">Permission</a></tt>
 object or an instance that represents an action on a resource. In this case, 
the instance is named <tt>printerPermission</tt>, the resource is 
<em>laserjet3000n</em>, and the action is <em>print</em>.   Then we pass 
<tt>printerPermission</tt> to the Subject's <tt><a class="external-link" 
href="static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isPermitted(java.util.List)">.isPermitted()</a></tt>
 method.  It will return true or false.  </p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-Subject currentUser =
-    SecurityUtils.getSubject();
-
-Permission printPermission = 
-<span class="code-keyword">new</span> 
PrinterPermission(&#8220;laserjet3000n&#8221;,&#8220;print&#8221;);
-
-If (currentUser.isPermitted(printPermission)) {
-    <span class="code-comment">//<span class="code-keyword">do</span> one 
thing (show the print button?)&#8207;
-</span>} <span class="code-keyword">else</span> {
-    <span class="code-comment">//don&#8217;t show the button?
-</span>}
-</pre>
-</div></div>
-
-<h4><a 
name="JavaAuthorizationGuide-PermissionCheck%28Stringbased%29"></a>Permission 
Check (String-based)</h4>
-<p>You can also a permission check using a simple string instead of a 
permission class.</p>
-
-<p>So, if you don't want to implement our <a class="external-link" 
href="static/current/apidocs/org/apache/shiro/authz/Permission.html">permission 
interface</a> then you just pass in a String.  In this example, we pass the 
<tt>.isPermitted()</tt> method a string, 
<tt>printer:print:LaserJet4400n</tt></p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-object">String</span> perm = 
&#8220;printer:print:laserjet4400n&#8221;;
-
-<span class="code-keyword">if</span>(currentUser.isPermitted(perm)){
-    <span class="code-comment">//show the print button?
-</span>} <span class="code-keyword">else</span> {
-    <span class="code-comment">//don&#8217;t show the button?
-</span>}
-</pre>
-</div></div>
-
-<p>You can construct the permission string the way you want so long as your <a 
href="realm.html" title="Realm">Realm</a> knows how to work with it.  In this 
example we use Shiro's optional permission syntax, <a href="permissions.html" 
title="Permissions">WildCardPermissions</a>.  WildCardPermissions are powerful 
and intuitive.  If you'd like to learn more about them then check out the <a 
class="external-link" 
href="static/current/apidocs/org/apache/shiro/authz/Permission.html">Permissions
 Documentation</a>.</p>
-
-<p>With string-based permission checks, you get the same functionality as the 
example before.  The benefit is that you are not forced to implement a 
permission interface and you can construct the permission via a simple string.  
The downside is that you don't have type safety and if you needed more 
complicated permission capabilitues that are outside the scope of what this 
represents, you're going to want to implement your own permission objects based 
on the permission interface.</p>
-
-<h3><a name="JavaAuthorizationGuide-AnnotationAuthorization"></a>Annotation 
Authorization</h3>
-
-<p>If you don't want to do code level authorization checks, then you can use 
Java Annotations as well.  Shiro offers a number of <a 
href="java-annotations-list.html" title="Java Annotations List">Java 
annotations</a> that allow you to annotate methods.  </p>
-
-<h4><a name="JavaAuthorizationGuide-EnablingAnnotationSupport"></a>Enabling 
Annotation Support</h4>
-<p>Before you can use Java annotations, you'll need to enable AOP support in 
your application. There are a number of different AOP frameworks so, 
unfortunately, there is no standard way to enable AOP in an application.</p>
-
-<p>For AspectJ, you can review our <a class="external-link" 
href="https://github.com/apache/shiro/tree/master/samples/aspectj";>AspectJ 
sample application</a>.</p>
-
-<p>For Spring, you can look into our <a href="spring.html" 
title="Spring">Spring Integration</a> documentation.</p>
-
-<p>For Guice, you can look into our <a href="guice.html" title="Guice">Guice 
Integration</a> documentation.</p>
-
-<h4><a name="JavaAuthorizationGuide-PermissionCheck"></a>Permission Check</h4>
-<p>In this example, we want to check that a user has the 
<tt>account:create</tt> permission before they can invoke the 
<tt>openAccount</tt> method.  If they do, then the method is called as 
expected, and if they don't, then an exception is thrown. </p>
-
-<p>Like programmatic checks, you can use the <a class="external-link" 
href="static/current/apidocs/org/apache/shiro/authz/Permission.html">Permission</a>
 objects or the simple string methods with this annotation.</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//Will <span class="code-keyword">throw</span> an 
AuthorizationException <span class="code-keyword">if</span> none
-</span><span class="code-comment">//of the caller&#8217;s roles imply the 
Account 
-</span><span class="code-comment">//'create' permission&#65533;
-</span>@RequiresPermissions(&#8220;account:create&#8221;)&#8207;
-<span class="code-keyword">public</span> void openAccount( Account acct ) { 
-    <span class="code-comment">//create the account
-</span>}
-</pre>
-</div></div>
-
-<h4><a name="JavaAuthorizationGuide-RoleCheck"></a>Role Check</h4>
-<p>In this example, we want to check that a user has the <tt>teller</tt> role 
before they can invoke the <tt>openAccount</tt> method.  If they do, then the 
method is called as expected, and if they don't, then an exception is 
thrown.</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//Throws an AuthorizationException <span 
class="code-keyword">if</span> the caller
-</span><span class="code-comment">//doesn&#8217;t have the 
&#8216;teller&#8217; role:
-</span>
-@RequiresRoles( &#8220;teller&#8221; )
-<span class="code-keyword">public</span> void openAccount( Account acct ) { 
-    <span class="code-comment">//<span class="code-keyword">do</span> 
something in here that only a teller
-</span>    <span class="code-comment">//should <span 
class="code-keyword">do</span>
-</span>}
-</pre>
-</div></div>
-
-<h3><a name="JavaAuthorizationGuide-JSPTagLibAuthorization"></a>JSP TagLib 
Authorization</h3>
-<p>For JSP/GSP based web applications, Shiro also offers a <a 
href="jsp-tag-library.html" title="JSP Tag Library">tag library</a> for you to 
use. </p>
-
-<p>In this example, we're going to show users with the <em>users:manage</em> 
permission a link to the Manage Users page.  If they do not have the 
permission, then we'll show them a nice message.</p>
-
-<p>First, we'll need to add the Shiro taglib to our web application. Next, we 
add the <tt>&lt;shiro:hasPermission&gt;</tt> tag with a check for 
<em>users:manage</em>.  Within the <tt>&lt;shiro:hasPermission&gt;</tt> tags we 
will place the code we want to execute if the user has the permission we're 
checking for.  If we want to take an action if the user lacks the permission, 
then we need to also add the <tt>&lt;shiro:lacksPermission&gt;</tt> tag, again 
checking for <em>users:manage</em>.  And any code we want to excute if the user 
lacks the permission will need to be placed within the 
<tt>&lt;shiro:lacksPermission&gt;</tt> tags.</p>
-
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-&lt;%@ taglib prefix=&#8220;shiro&#8221; uri=http:<span 
class="code-comment">//shiro.apache.org/tags %&gt;
-</span>&lt;html&gt;
-&lt;body&gt;
-    &lt;shiro:hasPermission name=&#8220;users:manage&#8221;&gt;
-        &lt;a href=&#8220;manageUsers.jsp&#8221;&gt;
-            Click here to manage users
-        &lt;/a&gt;
-    &lt;/shiro:hasPermission&gt;
-    &lt;shiro:lacksPermission name=&#8220;users:manage&#8221;&gt;
-        No user management <span class="code-keyword">for</span> you!
-    &lt;/shiro:lacksPermission&gt;
-&lt;/body&gt;
-&lt;/html&gt;
-</pre>
-</div></div>
-
-<p>Of course, there also tags for checking roles and other user data and 
states.</p>
-
-<p>For more information on JSP/GSP Tags please check out the <a 
href="jsp-tag-library.html" title="JSP Tag Library">JSP Tag Library</a> and for 
more information on integration your application in your web application, 
please read the <a href="web.html" title="Web">Web Integration 
Documentation</a></p>
-
-<h2><a name="JavaAuthorizationGuide-CachingAuthorization"></a>Caching 
Authorization</h2>
-<p>TBD</p>
-
-<h2><a name="JavaAuthorizationGuide-Lendahandwithdocumentation"></a>Lend a 
hand with documentation </h2>
-
-<p>While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time.  If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro. </p>
-
-<p>The easiest way to contribute your documentation is to send it to the <a 
class="external-link" href="http://shiro-user.582556.n2.nabble.com/"; 
rel="nofollow">User Forum</a> or the <a href="mailing-lists.html" 
title="Mailing Lists">User Mailing List</a>.</p>

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-authorization-guide.md.vtl
----------------------------------------------------------------------
diff --git a/java-authorization-guide.md.vtl b/java-authorization-guide.md.vtl
new file mode 100644
index 0000000..0b414c7
--- /dev/null
+++ b/java-authorization-guide.md.vtl
@@ -0,0 +1,255 @@
+<a name="JavaAuthorizationGuide-JavaAuthorizationGuidewithApacheShiro"></a>
+Java Authorization Guide with Apache Shiro
+==========================================
+
+Authorization, or access control, is the function of specifying access rights 
to resources. In other words, _who_ has access to _what_.
+
+Examples of authorization checks are: Is the user allowed to look at this 
webpage, edit this data, view this button, or print to this printer? Those are 
all decisions determining what a user has access to.
+
+<a name="JavaAuthorizationGuide-ElementsofAuthorization"></a>
+Elements of Authorization
+-------------------------
+
+Authorization has three core elements that we reference quite a bit in Shiro-- 
permissions, roles, and users.
+
+<a name="JavaAuthorizationGuide-PermissionsDefined"></a>
+#[[###Permissions Defined]]#
+
+<table align="right" width="275" style="margin-left: 20px; margin-bottom: 
20px; border-style: solid; border-width: 2px; border-color: navy" 
cellpadding="10px"><tr><td>
+<div id="border">
+  <h2>Related Content</h2>
+       
+  <h3><a href="authorization-features.html">Authorization Features</a></h3>
+  <p>Quick overview of permissions, roles, and users in Shiro. </br><span 
style="font-size:11"><a href="authorization-features.html">Read More 
&gt;&gt;</a></span></p>
+       
+  <h3><a href="authorization.html">Authorization Docs</a></h3>
+  <p>Full documentation on Apache Shiro's Authorization functionality. 
</br><span style="font-size:11"><a href="authorization.html">Read More 
&gt;&gt;</a></span></p>
+       
+  <h3><a href="get-started.html">Getting Started</a></h3>
+  <p>Resources, guides and tutorials for new Shiro users. </br><span 
style="font-size:11"><a href="get-started.html">Read More 
&gt;&gt;</a></span></p> 
+       
+  <h3><a href="10-minute-tutorial.html">10-Minute Shiro Tutorial</a></h3>
+  <p>Try Apache Shiro for yourself in under 10 minutes. </br><span 
style="font-size:11"><a href="10-minute-tutorial.html">Read More 
&gt;&gt;</a></span></p>
+       
+  <h3><a href="webapp-tutorial.html">Web App Tutorial</a></h3>
+  <p>Step-by-step tutorial for securing a web application with Shiro. 
</br><span style="font-size:11"><a href="webapp-tutorial.html">Read More 
&gt;&gt;</a></span></p>
+       
+</div>
+</td></tr></table>
+
+Permissions are the most atomic level of a security policy and they are 
statements of functionality. Permissions represent what can be done in your 
application. A well formed permission describes a resource types and what 
actions are possible when you interact with those resources. Can you _open_ a 
_door_? Can you _read_ a _file_? Can you _delete_ a _customer record_? Can you 
_push_ a _button_?
+
+Common actions for data-related resources are create, read, update, and 
delete, commonly referred to as CRUD.
+
+It is important to understand that permissions do not have knowledge of _who_ 
can perform the actions-- they are just statements of _what_ actions can be 
performed.
+
+<a name="JavaAuthorizationGuide-Levelsofpermissiongranularity"></a>
+#[[####Levels of permission granularity]]#
+
+The permissions above all specify an actions (open, read, delete, etc) on a 
resource (door, file, customer record, etc). In Shiro, you can define a 
permission to any depth you like. Here are a few common permission levels in 
order of granularity.
+
+*   Resource Level - This is the broadest and easiest to build. A user can 
edit customer records or open doors. The resource is specified but not a 
specific instance of that resource.
+*   Instance Level - The permission specifies the instance of a resource. A 
user can edit the customer record for IBM or open the kitchen door.
+*   Attribute Level - The permission now specifies an attribute of an instance 
or resource. A user can edit the address on the IBM customer record.
+
+For more information on Permissions please check out the [Permissions 
Documentation](permissions.html "Permissions")
+
+<a name="JavaAuthorizationGuide-RolesDefined"></a>
+#[[###Roles Defined]]#
+
+In the context of Authorization, Roles are effectively a collection of 
permissions used to simplify the management of permissions and users. So users 
can be assigned roles instead of being assigned permissions directly, which can 
get complicated with larger user bases and more complex applications. So, for 
example, a bank application might have an _administrator_ role or a _bank 
teller_ role.
+
+There are two types of roles that you need to be aware of and Shiro will 
support both.
+
+<a name="JavaAuthorizationGuide-ImplicitRoles"></a>
+#[[####Implicit Roles]]#
+
+Most people view roles as what we define as an implicit role where your 
application _implies_ a set of permissions because a user has a particular role 
as opposed to the role explicitly being assigned permissions or your 
application checking for those permissions. Role checks in code are generally a 
reflection of an implicit role. You can view patient data because you have the 
_administrator_ role. You can create an account because you have the _bank 
teller_ role. The fact that these names exist does not have a correlation to 
what the software can actually do. Most people use roles in this manner. It is 
easiest but it can create a lot of maintenance and management problems for all 
the but the simplest application.
+
+<a name="JavaAuthorizationGuide-ExplicitRoles"></a>
+#[[####Explicit Roles]]#
+
+An explicit role has permissions _explicitly_ assigned to it and therefore is 
an _explicit_ collection of permissions. Permission checks in code are a 
reflection of an explicit role. You can view patient data because because you 
have the _view patient data_ permission as part of your _administrator_ role. 
You can create an account because you have the _create account_ permission as 
part of your _bank teller_ role. You can perform these actions, not because of 
some implicit role name based on a string but because the corresponding 
permission was explicitly assigned to your role.
+
+The big benefits of explicit roles are easier manageability and lower 
maintenance of your application. If you ever need to add, remove, or change a 
role, you can do so without touching your source code. And in Shiro, you'll 
also be able to dynamically add, remove, or change roles at runtime and your 
authorization checks will always have up to date values. This means you won't 
have to force users to log out and log back in order to get their new 
permissions.
+
+<a name="JavaAuthorizationGuide-UsersDefined"></a>
+#[[###Users Defined]]#
+
+A user is the "who" of an application. In Shiro, though, the concept of a user 
is really the [Subject](subject.html "Subject") instance. We use word Subject 
instead of user because user usually implies a human being and in Shiro a 
Subject can be anything interacting with your application-- whether it be a 
human or a service.
+
+Users are allowed to perform certain actions in your application through their 
association with roles or direct permissions. So you are able to open a 
customer record because you've been assigned the _open customer record_ 
permission, either through a role you've been assigned or through a direct 
permission assignment.
+
+For more information on Users, aka Subjects, please check out the [Subject 
Documentation](subject.html "Subject").
+
+#info('Note', 'Ultimately, your <a href="realm.html" title="Realm">Realm</a> 
implementation is what communicates with your data source (RDBMS, LDAP, etc). 
So your realm is what will tell Shiro whether or not roles or permissions 
exist. You have full control over how your authorization model works.')
+
+<a name="JavaAuthorizationGuide-HowtoperformAuthorizationinJavawithShiro"></a>
+How to perform Authorization in Java with Shiro
+-----------------------------------------------
+
+Authorization in Shiro can be handled in four ways.
+
+*   Programmatically - You can perform authorization checks in your java code 
with structures like `if` and `else` blocks.
+*   JDK annotations - You can attach an authorization annotation to your Java 
methods
+*   JSP/GSP TagLibs - You can control jsp or gsp page output based on roles 
and permissions
+
+<a name="JavaAuthorizationGuide-ProgrammaticAuthorization"></a>
+#[[###Programmatic Authorization]]#
+
+Checking for permissions and roles, programmatically in your Java code is the 
traditional way of handling authorization. Here's how you can perform a 
permission check or role check in Shiro.
+
+<a name="JavaAuthorizationGuide-RoleCheck"></a>
+#[[####Role Check]]#
+
+This is an example of how you do a role check programmatically in your 
application. We want to check if a user has the _administrator_ role and if 
they do, then we'll show a special button, otherwise we won't show it.
+
+First we get access to the current user, the [Subject](subject.html 
"Subject"). Then we pass the _adminstrator_ to the Subject's 
[`.hasRole()`](static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#hasRole-java.lang.String-)
 method. It will return `TRUE` or `FALSE`.
+
+``` java
+//get the current Subject 
+Subject currentUser = SecurityUtils.getSubject();
+
+if (currentUser.hasRole("administrator")) {
+    //show a special button‏
+} else {
+    //don’t show the button?)‏
+}
+```
+
+Now a role based check is quick and easy to implement but it has a major 
drawback. It is implicit.
+
+What if you just want to add, remove, or redefine a role later? You'll have to 
crack open your source code and change all your role checks to reflect the 
change in your security model. You'll have to shut down the application, crack 
open the code, test it, and then restart it everytime.
+
+In very simple applications this is probably good enough but for larger apps 
this can be a major problem throughout the life of your application and drive a 
large maintenance cost for your software.
+
+<a name="JavaAuthorizationGuide-PermissionCheck"></a>
+#[[####Permission Check]]#
+
+This is an example of how you do security checks by permission. We want to 
check if a user has permission to print to laserjet3000n and if they do, then 
we'll show a print button, otherwise we won't show it. This is an example of an 
instance level permission or instance level authorization.
+
+Again, first you get access to the current user, the [Subject](subject.html 
"Subject"). Then you construct a 
[`Permission`](static/current/apidocs/org/apache/shiro/authz/Permission.html) 
object or an instance that represents an action on a resource. In this case, 
the instance is named `printerPermission`, the resource is _laserjet3000n_, and 
the action is _print_. Then we pass `printerPermission` to the Subject's 
[`.isPermitted()`](static/current/apidocs/org/apache/shiro/subject/Subject.html#[[#]]#isPermitted-java.util.List-)
 method. It will return true or false.
+
+``` java
+Subject currentUser = SecurityUtils.getSubject();
+
+Permission printPermission = new PrinterPermission("laserjet3000n","print");
+
+If (currentUser.isPermitted(printPermission)) {
+    //do one thing (show the print button?)‏
+} else {
+    //don’t show the button?
+}
+```
+
+<a name="JavaAuthorizationGuide-PermissionCheck%28Stringbased%29"></a>
+#[[####Permission Check (String-based)]]#
+
+You can also a permission check using a simple string instead of a permission 
class.
+
+So, if you don't want to implement our [permission 
interface](static/current/apidocs/org/apache/shiro/authz/Permission.html) then 
you just pass in a String. In this example, we pass the `.isPermitted()` method 
a string, `printer:print:LaserJet4400n`
+
+``` java
+String perm = "printer:print:laserjet4400n";
+
+if(currentUser.isPermitted(perm)){
+    //show the print button?
+} else {
+    //don’t show the button?
+}
+```
+
+You can construct the permission string the way you want so long as your 
[Realm](realm.html "Realm") knows how to work with it. In this example we use 
Shiro's optional permission syntax, [WildCardPermissions](permissions.html 
"Permissions"). WildCardPermissions are powerful and intuitive. If you'd like 
to learn more about them then check out the [Permissions 
Documentation](static/current/apidocs/org/apache/shiro/authz/Permission.html).
+
+With string-based permission checks, you get the same functionality as the 
example before. The benefit is that you are not forced to implement a 
permission interface and you can construct the permission via a simple string. 
The downside is that you don't have type safety and if you needed more 
complicated permission capabilitues that are outside the scope of what this 
represents, you're going to want to implement your own permission objects based 
on the permission interface.
+
+<a name="JavaAuthorizationGuide-AnnotationAuthorization"></a>
+#[[###Annotation Authorization]]#
+
+If you don't want to do code level authorization checks, then you can use Java 
Annotations as well. Shiro offers a number of [Java 
annotations](java-annotations-list.html "Java Annotations List") that allow you 
to annotate methods.
+
+<a name="JavaAuthorizationGuide-EnablingAnnotationSupport"></a>
+#[[####Enabling Annotation Support]]#
+
+Before you can use Java annotations, you'll need to enable AOP support in your 
application. There are a number of different AOP frameworks so, unfortunately, 
there is no standard way to enable AOP in an application.
+
+For AspectJ, you can review our [AspectJ sample 
application](https://github.com/apache/shiro/tree/master/samples/aspectj).
+
+For Spring, you can look into our [Spring Integration](spring.html "Spring") 
documentation.
+
+For Guice, you can look into our [Guice Integration](guice.html "Guice") 
documentation.
+
+<a name="JavaAuthorizationGuide-PermissionCheck"></a>
+#[[####Permission Check]]#
+
+In this example, we want to check that a user has the `account:create` 
permission before they can invoke the `openAccount` method. If they do, then 
the method is called as expected, and if they don't, then an exception is 
thrown.
+
+Like programmatic checks, you can use the 
[Permission](static/current/apidocs/org/apache/shiro/authz/Permission.html) 
objects or the simple string methods with this annotation.
+
+``` java
+//Will throw an AuthorizationException if none
+//of the caller’s roles imply the Account
+//'create' permission
+@RequiresPermissions("account:create")‏
+public void openAccount( Account acct ) {
+    //create the account
+}
+```
+
+<a name="JavaAuthorizationGuide-RoleCheck"></a>
+#[[####Role Check]]#
+
+In this example, we want to check that a user has the `teller` role before 
they can invoke the `openAccount` method. If they do, then the method is called 
as expected, and if they don't, then an exception is thrown.
+
+``` java
+//Throws an AuthorizationException if the caller
+//doesn’t have the ‘teller’ role:
+@RequiresRoles( "teller" )
+public void openAccount( Account acct ) {
+    //do something in here that only a teller
+    //should do
+}
+```
+
+<a name="JavaAuthorizationGuide-JSPTagLibAuthorization"></a>
+#[[###JSP TagLib Authorization]]#
+
+For JSP/GSP based web applications, Shiro also offers a [tag 
library](jsp-tag-library.html "JSP Tag Library") for you to use.
+
+In this example, we're going to show users with the _users:manage_ permission 
a link to the Manage Users page. If they do not have the permission, then we'll 
show them a nice message.
+
+First, we'll need to add the Shiro taglib to our web application. Next, we add 
the `<shiro:hasPermission>` tag with a check for _users:manage_. Within the 
`<shiro:hasPermission>` tags we will place the code we want to execute if the 
user has the permission we're checking for. If we want to take an action if the 
user lacks the permission, then we need to also add the 
`<shiro:lacksPermission>` tag, again checking for _users:manage_. And any code 
we want to excute if the user lacks the permission will need to be placed 
within the `<shiro:lacksPermission>` tags.
+
+``` html
+<%@ taglib prefix="shiro" uri=http://shiro.apache.org/tags %>
+<html>
+<body>
+    <shiro:hasPermission name="users:manage">
+        <a href="manageUsers.jsp">
+            Click here to manage users
+        </a>
+    </shiro:hasPermission>
+    <shiro:lacksPermission name="users:manage">
+        No user management for you!
+    </shiro:lacksPermission>
+</body>
+</html>
+```
+
+Of course, there also tags for checking roles and other user data and states.
+
+For more information on JSP/GSP Tags please check out the [JSP Tag 
Library](jsp-tag-library.html "JSP Tag Library") and for more information on 
integration your application in your web application, please read the [Web 
Integration Documentation](web.html "Web")
+
+<a name="JavaAuthorizationGuide-CachingAuthorization"></a>
+Caching Authorization
+---------------------
+
+TBD
+
+<a name="JavaAuthorizationGuide-Lendahandwithdocumentation"></a>
+Lend a hand with documentation
+------------------------------
+
+While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time. If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro.
+
+The easiest way to contribute your documentation is to send it to the [User 
Forum](http://shiro-user.582556.n2.nabble.com/) or the [User Mailing 
List](mailing-lists.html "Mailing Lists").
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-cryptography-guide.html.vtl
----------------------------------------------------------------------
diff --git a/java-cryptography-guide.html.vtl b/java-cryptography-guide.html.vtl
deleted file mode 100644
index 6707406..0000000
--- a/java-cryptography-guide.html.vtl
+++ /dev/null
@@ -1,95 +0,0 @@
-<h1><a 
name="JavaCryptographyGuide-JavaCryptographyGuidewithApacheShiro"></a>Java 
Cryptography Guide with Apache Shiro</h1>
-
-
-<div class="addthis_toolbox addthis_default_style">
-<a class="addthis_button_compact" 
href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=ra-4d66ef016022c3bd";>Share</a>
-<span class="addthis_separator">|</span>
-<a class="addthis_button_preferred_1"></a>
-<a class="addthis_button_preferred_2"></a>
-<a class="addthis_button_preferred_3"></a>
-<a class="addthis_button_preferred_4"></a>
-</div>
-<script type="text/javascript">var addthis_config = 
{"data_track_clickback":true};</script>
-<script type="text/javascript" 
src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d66ef016022c3bd";></script>
-
-
-<p><br clear="none" class="atl-forced-newline">
-Cryptography is the protecting of information from undesired access by hiding 
it or converting it into nonsense so that no one can read it.</p>
-
-<p>Shiro is a major part of Shiro because we wanted to provide you with 
simplicity on what is typically a very complex topic.  For example, the Java 
Cryptophay Environments (JCE) already handles cryptogrpahy in a Java 
environment but is very difficult to learn and use.  So we grabbed the concepts 
made available by the JCE API and make them available to us mortals.  In 
addition, all of the calls in the JCE are procedural which doesn't fit in 
Java's Object Oriented paradigm.  So in Shiro, our cryptography features are 
all object oriented.</p>
-
-<h2><a name="JavaCryptographyGuide-ElementsofCryptography"></a>Elements of 
Cryptography</h2>
-<p>Cryptogrpahy has two core elements in Shiro-- ciphers and hashes.  </p>
-
-<h3><a name="JavaCryptographyGuide-CiphersDefined"></a>Ciphers Defined</h3>
-<p>Ciphers are algorightms that can either encrypt or decrypt based on public 
or private key pair. And there are two different types of ciphers:</p>
-
-<ul class="alternate" type="square"><li>Symmetric Cipher - encrypts and 
decrypts using the same key.</li></ul>
-
-
-<ul class="alternate" type="square"><li>Asymmetric Cipher - uses different 
keys for encryption and decryption.</li></ul>
-
-
-<p>Both cipher type are support in Shiro.</p>
-
-<h3><a name="JavaCryptographyGuide-HashesDefined"></a>Hashes Defined</h3>
-<p>A hash is a one-way irreversible conversion of an input source.  In the 
JDK, a hash is referred to as a message digest.  A cryptographic hash and a 
message digests are the same thing and both terms or correct.</p>
-
-<h4><a name="JavaCryptographyGuide-CommonusesforHashes"></a>Common uses for 
Hashes</h4>
-<p>Hashes are often used to transforms credentials like passwords or biometric 
data.  It's a one way transformation so you can never see what the original 
value was.  This is a very safe way of storing passwords so that no one other 
than the user will ever know a password, even if your system is compromised.</p>
-
-<p>In addition, Shiro's hashes can be used with any type of data with an 
underlying byte array.  Examples of this data include files, streams, byte 
arrays, strings, and character arrays.</p>
-
-<h2><a name="JavaCryptographyGuide-CipherFeatures"></a>Cipher Features</h2>
-<h3><a 
name="JavaCryptographyGuide-Shiro%27sCipherServiceInterface"></a>Shiro's 
CipherService Interface</h3>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-keyword">public</span> <span 
class="code-keyword">interface</span> CipherService {
-
-   ByteSource encrypt( <span class="code-object">byte</span>[] raw, <span 
class="code-object">byte</span>[] key);
-
-   void encrypt(InputStream in, OutputStream out, <span 
class="code-object">byte</span>[] key);
-
-   ByteSource decrypt( <span class="code-object">byte</span>[] cipherText, 
<span class="code-object">byte</span>[] key);
-
-   void decrypt(InputStream in, OutputStream out, <span 
class="code-object">byte</span>[] key);  
-}
-</pre>
-</div></div>
-
-<h2><a name="JavaCryptographyGuide-HashFeatures"></a>Hash Features</h2>
-#tip('Tip', 'Salts are important when hashing ...')
-
-#tip('Tip', 'Repeated hashes are important when hashing ...')
-
-<h3><a name="JavaCryptographyGuide-Shiro%27sHashInterface"></a>Shiro's Hash 
Interface</h3>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-keyword">public</span> <span 
class="code-keyword">interface</span> Hash {
-   <span class="code-object">byte</span>[] getBytes();
-   <span class="code-object">String</span> toHex();
-   <span class="code-object">String</span> toBase64();
-}
-</pre>
-</div></div>
-
-<h3><a 
name="JavaCryptographyGuide-ExamplesofhowtouseHashesinyourcode"></a>Examples of 
how to use Hashes in your code</h3>
-<div class="code panel" style="border-width: 1px;"><div class="codeContent 
panelContent">
-<pre class="code-java">
-<span class="code-comment">//some examples:
-</span><span class="code-keyword">new</span> 
Md5Hash(&#8220;foo&#8221;).toHex();
-
-<span class="code-comment">//File MD5 Hash value <span 
class="code-keyword">for</span> checksum:
-</span><span class="code-keyword">new</span> MD5Hash( aFile ).toHex();
-
-<span class="code-comment">//store a password, but not raw:
-</span><span class="code-keyword">new</span> Sha256(aPassword, salt,
-           1024).toBase64();
-</pre>
-</div></div>
-
-<h2><a name="JavaCryptographyGuide-Lendahandwithdocumentation"></a>Lend a hand 
with documentation </h2>
-
-<p>While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time.  If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro. </p>
-
-<p>The easiest way to contribute your documentation is to send it to the <a 
class="external-link" href="http://shiro-user.582556.n2.nabble.com/"; 
rel="nofollow">User Forum</a> or the <a href="mailing-lists.html" 
title="Mailing Lists">User Mailing List</a>.</p>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro-site/blob/f37b5848/java-cryptography-guide.md.vtl
----------------------------------------------------------------------
diff --git a/java-cryptography-guide.md.vtl b/java-cryptography-guide.md.vtl
new file mode 100644
index 0000000..861d418
--- /dev/null
+++ b/java-cryptography-guide.md.vtl
@@ -0,0 +1,109 @@
+<a name="JavaCryptographyGuide-JavaCryptographyGuidewithApacheShiro"></a>
+Java Cryptography Guide with Apache Shiro
+=========================================
+
+<div class="addthis_toolbox addthis_default_style">
+<a class="addthis_button_compact" 
href="http://www.addthis.com/bookmark.php?v=250&amp;pubid=ra-4d66ef016022c3bd";>Share</a>
+<span class="addthis_separator">|</span>
+<a class="addthis_button_preferred_1"></a>
+<a class="addthis_button_preferred_2"></a>
+<a class="addthis_button_preferred_3"></a>
+<a class="addthis_button_preferred_4"></a>
+</div>
+<script type="text/javascript">var addthis_config = 
{"data_track_clickback":true};</script>
+<script type="text/javascript" 
src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4d66ef016022c3bd";></script>
+
+
+Cryptography is the protecting of information from undesired access by hiding 
it or converting it into nonsense so that no one can read it.
+
+Shiro is a major part of Shiro because we wanted to provide you with 
simplicity on what is typically a very complex topic. For example, the Java 
Cryptophay Environments (JCE) already handles cryptogrpahy in a Java 
environment but is very difficult to learn and use. So we grabbed the concepts 
made available by the JCE API and make them available to us mortals. In 
addition, all of the calls in the JCE are procedural which doesn't fit in 
Java's Object Oriented paradigm. So in Shiro, our cryptography features are all 
object oriented.
+
+<a name="JavaCryptographyGuide-ElementsofCryptography"></a>
+Elements of Cryptography
+------------------------
+
+Cryptogrpahy has two core elements in Shiro-- ciphers and hashes.
+
+<a name="JavaCryptographyGuide-CiphersDefined"></a>
+#[[###Ciphers Defined]]#
+
+Ciphers are algorightms that can either encrypt or decrypt based on public or 
private key pair. And there are two different types of ciphers:
+
+*   Symmetric Cipher - encrypts and decrypts using the same key.
+
+*   Asymmetric Cipher - uses different keys for encryption and decryption.
+
+Both cipher type are support in Shiro.
+
+<a name="JavaCryptographyGuide-HashesDefined"></a>
+#[[###Hashes Defined]]#
+
+A hash is a one-way irreversible conversion of an input source. In the JDK, a 
hash is referred to as a message digest. A cryptographic hash and a message 
digests are the same thing and both terms or correct.
+
+<a name="JavaCryptographyGuide-CommonusesforHashes"></a>
+#[[####Common uses for Hashes]]#
+
+Hashes are often used to transforms credentials like passwords or biometric 
data. It's a one way transformation so you can never see what the original 
value was. This is a very safe way of storing passwords so that no one other 
than the user will ever know a password, even if your system is compromised.
+
+In addition, Shiro's hashes can be used with any type of data with an 
underlying byte array. Examples of this data include files, streams, byte 
arrays, strings, and character arrays.
+
+<a name="JavaCryptographyGuide-CipherFeatures"></a>
+Cipher Features
+---------------
+
+<a name="JavaCryptographyGuide-Shiro%27sCipherServiceInterface"></a>
+#[[###Shiro's CipherService Interface]]#
+
+``` java
+public interface CipherService {
+
+   ByteSource encrypt( byte[] raw, byte[] key);
+
+   void encrypt(InputStream in, OutputStream out, byte[] key);
+
+   ByteSource decrypt( byte[] cipherText, byte[] key);
+
+   void decrypt(InputStream in, OutputStream out, byte[] key);
+}
+```
+
+<a name="JavaCryptographyGuide-HashFeatures"></a>
+Hash Features
+-------------
+
+#tip('Tip', 'Salts are important when hashing ...')
+
+#tip('Tip', 'Repeated hashes are important when hashing ...')
+
+<a name="JavaCryptographyGuide-Shiro%27sHashInterface"></a>
+#[[###Shiro's Hash Interface]]#
+
+``` java
+public interface Hash {
+   byte[] getBytes();
+   String toHex();
+   String toBase64();
+}
+```
+
+<a name="JavaCryptographyGuide-ExamplesofhowtouseHashesinyourcode"></a>
+#[[###Examples of how to use Hashes in your code]]#
+
+``` java
+//some examples: 
+new Md5Hash(“foo”).toHex();
+
+//File MD5 Hash value for checksum: 
+new MD5Hash( aFile ).toHex();
+
+//store a password, but not raw: 
+new Sha256(aPassword, salt, 1024).toBase64();
+```
+
+<a name="JavaCryptographyGuide-Lendahandwithdocumentation"></a>
+Lend a hand with documentation
+------------------------------
+
+While we hope this documentation helps you with the work you're doing with 
Apache Shiro, the community is improving and expanding the documentation all 
the time. If you'd like to help the Shiro project, please consider corrected, 
expanding, or adding documentation where you see a need. Every little bit of 
help you provide expands the community and in turn improves Shiro.
+
+The easiest way to contribute your documentation is to send it to the [User 
Forum](http://shiro-user.582556.n2.nabble.com/) or the [User Mailing 
List](mailing-lists.html "Mailing Lists").
\ No newline at end of file

Reply via email to