| <!DOCTYPE html> |
| <!-- |
| | Generated by Apache Maven Doxia Site Renderer 1.9.2 from xdocs/index.xml at 19 January 2022 |
| | Rendered using Apache Maven Fluido Skin 1.9 |
| --> |
| <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> |
| <head> |
| <meta charset="UTF-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| <meta name="generator" content="Apache Maven Doxia Site Renderer 1.9.2" /> |
| <meta name="author" content="Eric PUgh" /> |
| <title>Fulcrum Crypto – Crypto Component</title> |
| <link rel="stylesheet" href="./css/apache-maven-fluido-1.9.min.css" /> |
| <link rel="stylesheet" href="./css/site.css" /> |
| <link rel="stylesheet" href="./css/print.css" media="print" /> |
| <script src="./js/apache-maven-fluido-1.9.min.js"></script> |
| </head> |
| <body class="topBarDisabled"> |
| <a href="https://github.com/apache/turbine-core"> |
| <img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;" |
| src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" |
| alt="Fork me on GitHub"> |
| </a> |
| <div class="container-fluid"> |
| <header> |
| <div id="banner"> |
| <div class="pull-left"><a href="https://turbine.apache.org/" id="bannerLeft" title="Apache Turbine"><img src="https://turbine.apache.org/images/turbine-project.png" alt="Apache Turbine"/></a></div> |
| <div class="pull-right"></div> |
| <div class="clear"><hr/></div> |
| </div> |
| |
| <div id="breadcrumbs"> |
| <ul class="breadcrumb"> |
| <li id="publishDate">Last Published: 19 January 2022<span class="divider">|</span> |
| </li> |
| <li id="projectVersion">Version: 1.0.9-SNAPSHOT</li> |
| <li class="pull-right"><span class="divider">|</span> |
| <a href="https://turbine.apache.org/fulcrum/" class="externalLink" title="Fulcrum">Fulcrum</a></li> |
| <li class="pull-right"><span class="divider">|</span> |
| <a href="https://turbine.apache.org/" class="externalLink" title="Turbine">Turbine</a></li> |
| <li class="pull-right"><a href="https://www.apache.org" class="externalLink" title="Apache">Apache</a></li> |
| </ul> |
| </div> |
| </header> |
| <div class="row-fluid"> |
| <header id="leftColumn" class="span2"> |
| <nav class="well sidebar-nav"> |
| <ul class="nav nav-list"> |
| <li class="nav-header">Overview</li> |
| <li class="active"><a href="#"><span class="none"></span>About</a></li> |
| <li class="nav-header">Project Documentation</li> |
| <li><a href="project-info.html" title="Project Information"><span class="icon-chevron-down"></span>Project Information</a> |
| <ul class="nav nav-list"> |
| <li><a href="dependencies.html" title="Dependencies"><span class="none"></span>Dependencies</a></li> |
| <li><a href="dependency-info.html" title="Dependency Information"><span class="none"></span>Dependency Information</a></li> |
| <li><a href="distribution-management.html" title="Distribution Management"><span class="none"></span>Distribution Management</a></li> |
| <li class="active"><a href="#"><span class="none"></span>About</a></li> |
| <li><a href="issue-management.html" title="Issue Management"><span class="none"></span>Issue Management</a></li> |
| <li><a href="licenses.html" title="Licenses"><span class="none"></span>Licenses</a></li> |
| <li><a href="mailing-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a></li> |
| <li><a href="plugin-management.html" title="Plugin Management"><span class="none"></span>Plugin Management</a></li> |
| <li><a href="plugins.html" title="Plugins"><span class="none"></span>Plugins</a></li> |
| <li><a href="scm.html" title="Source Code Management"><span class="none"></span>Source Code Management</a></li> |
| <li><a href="summary.html" title="Summary"><span class="none"></span>Summary</a></li> |
| <li><a href="team.html" title="Team"><span class="none"></span>Team</a></li> |
| </ul></li> |
| <li><a href="project-reports.html" title="Project Reports"><span class="icon-chevron-right"></span>Project Reports</a></li> |
| <li class="nav-header">Apache</li> |
| <li><a href="https://www.apache.org/" class="externalLink" title="Apache Website"><span class="none"></span>Apache Website</a></li> |
| <li><a href="https://www.apache.org/licenses/" class="externalLink" title="License"><span class="none"></span>License</a></li> |
| <li><a href="https://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How the ASF works"><span class="none"></span>How the ASF works</a></li> |
| <li><a href="https://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsorship"><span class="none"></span>Sponsorship</a></li> |
| <li><a href="https://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks"><span class="none"></span>Thanks</a></li> |
| <li><a href="https://www.apache.org/security/" class="externalLink" title="Security"><span class="none"></span>Security</a></li> |
| </ul> |
| </nav> |
| <div class="well sidebar-nav"> |
| <form id="search-form" action="https://www.google.com/search" method="get" > |
| <input value="http://turbine.apache.org/fulcrum/fulcrum-crypto" name="sitesearch" type="hidden"/> |
| <input class="search-query" name="q" id="query" type="text" /> |
| </form> |
| <script>asyncJs( 'https://cse.google.com/brand?form=search-form' )</script> |
| <hr /> |
| <div id="poweredBy"> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <div class="clear"></div> |
| <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a> |
| </div> |
| </div> |
| </header> |
| <main id="bodyColumn" class="span10" > |
| |
| |
| |
| <section> |
| <h2><a name="Overview"></a>Overview</h2> |
| |
| <p> |
| The Crypto Service allows an application to request various encryption |
| algorithms. |
| </p> |
| |
| |
| <p> |
| It is written for use in Turbine but it can be used in any container |
| compatible with Avalon's ECM container. |
| </p> |
| </section> |
| |
| <section> |
| <h2><a name="Configuration"></a>Configuration</h2> |
| <section> |
| <h3><a name="Role_Configuration"></a>Role Configuration</h3> |
| |
| <div class="source"><pre class="prettyprint"> |
| <role |
| name="org.apache.fulcrum.crypto.CryptoService" |
| shorthand="crypto" |
| default-class="org.apache.fulcrum.crypto.DefaultCryptoService"/> |
| </pre></div> |
| </section> |
| |
| <section> |
| <h3><a name="Component_Configuration"></a>Component Configuration</h3> |
| |
| <table border="0" class="table table-striped"> |
| |
| <tr class="a"> |
| |
| <th>Item</th> |
| |
| <th>Datatype</th> |
| |
| <th>Cardinality</th> |
| |
| <th>Description</th> |
| </tr> |
| |
| <tr class="b"> |
| |
| <td>algorithm</td> |
| |
| <td>Complex</td> |
| |
| <td>[0|1]</td> |
| |
| <td> |
| This element controls the various encryption providers. All sub-elements |
| of this element define the name of the provider as the element name and |
| the class that implements the provider as its value. See the configuration |
| example. The algorithm <code>default</code> can be used to override the |
| default which is JavaCrypt. |
| </td> |
| </tr> |
| </table> |
| </section> |
| |
| <section> |
| <h3><a name="Component_Configuration_Example"></a>Component Configuration Example</h3> |
| |
| <div class="source"><pre class="prettyprint"> |
| <crypto> |
| <algorithm> |
| <unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix> |
| <clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear> |
| <java>org.apache.fulcrum.crypto.provider.JavaCrypt</java> |
| <oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava> |
| </algorithm> |
| </crypto> |
| </pre></div> |
| </section> |
| </section> |
| |
| <section> |
| <h2><a name="Usage"></a>Usage</h2> |
| |
| <p> |
| If you want to encrypt a clear text with a MessageDigest Cipher, you |
| can do it like this: |
| </p> |
| |
| |
| <div class="source"><pre class="prettyprint"> |
| import org.apache.fulcrum.crypto.CryptoAlgorithm; |
| import org.apache.fulcrum.crypto.CryptoService; |
| |
| public class CryptoExample |
| { |
| public String doMD5Encryption(String input) |
| { |
| CryptoService cs = (CryptoService) avalonComponentService.lookup(CryptoService.ROLE); |
| CryptoAlgorithm ca = CryptoService.getCryptoAlgorithm("default"); |
| |
| ca.setCipher("MD5"); |
| |
| return ca.encrypt(input); |
| } |
| } |
| </pre></div> |
| |
| |
| <p> |
| To see an example, look at the test case |
| <a href="xref-test/org/apache/fulcrum/crypto/CryptoServiceTest.html">CryptoServiceTest</a>. |
| </p> |
| </section> |
| |
| <section> |
| <h2><a name="Default_Provider"></a>Default Provider</h2> |
| |
| <p> |
| In the source code and the example above, there is talk |
| about a "default" provider which is used if no encryption algorithm is |
| specifically requested. The reason for this comes from the first user |
| of the crypto service, the |
| <a class="externalLink" href="http://turbine.apache.org/turbine/turbine-2.3.3/services/security-service.html">Turbine Security Service</a>. |
| It gives you the |
| ability to select an encryption algorithm like MD5 or SHA1 which is in |
| turn used with the normal java crypto providers. As we just wanted to |
| "add" new algorithms and still be able to use the old java.security |
| names like MD5 and SHA1, we decided to add a "catchall" algorithm to |
| the crypto service. |
| </p> |
| |
| <p> |
| If you don't set the default provider explicitly, the |
| org.apache.fulcrum.crypto.provider.JavaCrypt class is |
| used. If you don't set the Cipher of this class explicitly, then SHA |
| is used. |
| </p> |
| </section> |
| |
| <section> |
| <h2><a name="Included_Providers"></a>Included Providers</h2> |
| |
| <p>The following algorithm providers are included in the |
| Cryptoservice:</p> |
| |
| |
| <p> |
| </p> |
| <ol style="list-style-type: decimal"> |
| |
| <li> |
| <b>ClearCrypt</b> |
| (org.apache.fulcrum.crypto.provider.ClearCrypt). |
| This is the simplest algorithm which does nothing. It is still |
| useful because you can use the Crypto Service all the time even |
| if you don't want to actually encrypt something. Just request |
| the "clear" algorithm. |
| </li> |
| |
| <li> |
| <b>UnixCrypt</b> |
| (org.apache.fulcrum.crypto.provider.UnixCrypt). |
| This is an implementation of the Unix crypt(3) algorithm. Its |
| main use is when you need to access legacy information or |
| databases which already contain crypted passwords. |
| </li> |
| |
| <li> |
| <b>JavaCrypt</b> |
| (org.apache.fulcrum.crypto.provider.JavaCrypt). |
| This is the default crypto provider. It implements the normal |
| Java MessageDigest ciphers You don't need to have this, it is |
| the default if no algorithms are given. The default |
| provider gives you all the Java MessageDigest Ciphers including |
| MD5, and SHA1. |
| </li> |
| |
| <li> |
| <b>OldJavaCrypt</b> |
| (org.apache.fulcrum.crypto.provider.OldJavaCrypt). |
| Accessing the MessageDigest functions from java.security was |
| buggy in Turbine 2.1, because the Security Service didn't pad |
| the base64 values correctly but simply cut them |
| off after 20 bytes. If you're stuck with an old database full of |
| passwords and can't upgrade, please use this provider to keep |
| going. DO NOT USE THIS PROVIDER FOR NEW APPLICATIONS!. |
| </li> |
| </ol> |
| |
| </section> |
| |
| |
| </main> |
| </div> |
| </div> |
| <hr/> |
| <footer> |
| <div class="container-fluid"> |
| <div class="row-fluid"> |
| <p>© 2005–2022 |
| <a href="https://www.apache.org/">The Apache Software Foundation</a> |
| </p> |
| </div> |
| </div> |
| </footer> |
| </body> |
| </html> |