blob: e84fe50437bac4966de529698eba2af048a7893f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CryptorFactory.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">jUDDI Core Services</a> &gt; <a href="index.source.html" class="el_package">org.apache.juddi.cryptor</a> &gt; <span class="el_source">CryptorFactory.java</span></div><h1>CryptorFactory.java</h1><pre class="source lang-java linenums">/*
* Copyright 2001-2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.juddi.cryptor;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.juddi.ClassUtil;
import org.apache.juddi.config.AppConfig;
import org.apache.juddi.config.Property;
import org.apache.juddi.v3.client.cryptor.Cryptor;
/**
* Used to create the org.apache.juddi.cryptor.Cryptor implementation as
* specified by the 'juddi.cryptor' property. Defaults to
* org.apache.juddi.cryptor.DefaultCryptor if an implementation is not
* specified.&lt;Br&gt;
* &lt;br&gt;
* This class is a special instance that loads from the juddi server side config file.&lt;br&gt;
*
* Use org.apache.juddi.v3.client.cryptor.CryptorFactor for all client side actions
* @see org.apache.juddi.v3.client.cryptor.CryptorFactory
* @author Steve Viens (sviens@apache.org)
* @author &lt;a href=&quot;mailto:jfaath@apache.org&quot;&gt;Jeff Faath&lt;/a&gt;
*/
<span class="nc" id="L41">public abstract class CryptorFactory {</span>
<span class="fc" id="L43"> private static final Log log = LogFactory.getLog(CryptorFactory.class);</span>
// the shared Cryptor instance
<span class="fc" id="L45"> private static Cryptor cryptor = null;</span>
/*
* Returns a new instance of a CryptorFactory.
*
* @return Cryptor
*/
public static synchronized Cryptor getCryptor() {
<span class="fc bfc" id="L53" title="All 2 branches covered."> if (cryptor == null) {</span>
<span class="fc" id="L54"> cryptor = createCryptor();</span>
}
<span class="fc" id="L56"> return cryptor;</span>
}
public static synchronized Cryptor getCryptor(String className) throws Exception {
<span class="nc" id="L60"> return org.apache.juddi.v3.client.cryptor.CryptorFactory.getCryptor(className);</span>
}
/*
* Returns a new instance of a Cryptor.
*
* @return Cryptor
*/
private static synchronized Cryptor createCryptor() {
<span class="pc bpc" id="L70" title="1 of 2 branches missed."> if (cryptor != null) {</span>
<span class="nc" id="L71"> return cryptor;</span>
}
// grab class name of the Cryptor implementation to create
<span class="fc" id="L75"> String className = Property.DEFAULT_CRYPTOR;</span>
try {
// grab class name of the Authenticator implementation to create
<span class="fc" id="L78"> className = AppConfig.getConfiguration().getString(Property.JUDDI_CRYPTOR, Property.DEFAULT_CRYPTOR);</span>
<span class="nc" id="L79"> } catch (ConfigurationException ce) {</span>
<span class="nc" id="L80"> log.error(&quot;Configuration exception occurred retrieving: &quot; + Property.JUDDI_CRYPTOR, ce);</span>
<span class="fc" id="L81"> }</span>
// write the Cryptor implementation name to the log
<span class="fc" id="L84"> log.debug(&quot;Cryptor Implementation = &quot; + className);</span>
<span class="fc" id="L86"> Class&lt;?&gt; cryptorClass = null;</span>
try {
// Use Loader to locate &amp; load the Cryptor implementation
<span class="fc" id="L89"> cryptorClass = ClassUtil.forName(className, CryptorFactory.class);</span>
<span class="nc" id="L90"> } catch (ClassNotFoundException e) {</span>
<span class="nc" id="L91"> log.error(&quot;The specified Cryptor class '&quot; + className + &quot;' was not found in classpath.&quot;);</span>
<span class="nc" id="L92"> log.error(e);</span>
<span class="fc" id="L93"> }</span>
<span class="pc bpc" id="L95" title="1 of 2 branches missed."> if (cryptorClass != null) {</span>
try {
// try to instantiate the Cryptor implementation
<span class="fc" id="L98"> cryptor = (Cryptor) cryptorClass.newInstance();</span>
<span class="nc" id="L99"> } catch (Exception e) {</span>
<span class="nc" id="L100"> log.error(&quot;Exception while attempting to instantiate the implementation of Cryptor: &quot; + cryptorClass.getName() + &quot;\n&quot; + e.getMessage());</span>
<span class="nc" id="L101"> log.error(e);</span>
<span class="fc" id="L102"> }</span>
}
<span class="fc" id="L105"> return cryptor;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>