blob: 3a1d0309a5ed3dbe2a91760a79999707dc661b38 [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="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>CryptoConfigBuilder.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="right"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Coverage Report</a> &gt; <a href="index.html" class="el_package">org.apache.rampart.policy.builders</a> &gt; <span class="el_source">CryptoConfigBuilder.java</span></div><h1>CryptoConfigBuilder.java</h1><pre class="source lang-java linenums">/*
* Copyright 2001-2004 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.rampart.policy.builders;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.builders.AssertionBuilder;
import org.apache.rampart.policy.model.CryptoConfig;
import org.apache.rampart.policy.model.RampartConfig;
import javax.xml.namespace.QName;
import java.util.Iterator;
import java.util.Properties;
<span class="fc" id="L31">public class CryptoConfigBuilder implements AssertionBuilder&lt;OMElement&gt; {</span>
public Assertion build(OMElement element, AssertionBuilderFactory factory)
throws IllegalArgumentException {
<span class="fc" id="L36"> CryptoConfig cryptoCofig = new CryptoConfig();</span>
<span class="fc" id="L38"> OMAttribute attribute = element.getAttribute(new QName(CryptoConfig.PROVIDER_ATTR));</span>
<span class="fc" id="L39"> cryptoCofig.setProvider(attribute.getAttributeValue().trim());</span>
<span class="fc" id="L41"> OMAttribute cryptoKeyAttr = element.getAttribute(new QName(CryptoConfig.CRYPTO_KEY_ATTR));</span>
<span class="pc bpc" id="L42" title="1 of 2 branches missed."> if(cryptoKeyAttr != null){</span>
<span class="nc" id="L43"> cryptoCofig.setCryptoKey(cryptoKeyAttr.getAttributeValue().trim());</span>
}
<span class="fc" id="L46"> OMAttribute cacheRefreshIntAttr = element.getAttribute(new QName(CryptoConfig.CACHE_REFRESH_INTVL));</span>
<span class="pc bpc" id="L47" title="1 of 2 branches missed."> if(cacheRefreshIntAttr != null){</span>
<span class="nc" id="L48"> cryptoCofig.setCacheRefreshInterval(cacheRefreshIntAttr.getAttributeValue().trim());</span>
}
<span class="fc" id="L51"> OMAttribute enableCryptoCacheAttr = element.getAttribute(new QName(CryptoConfig.CACHE_ENABLED));</span>
<span class="pc bpc" id="L52" title="1 of 2 branches missed."> if(enableCryptoCacheAttr != null){</span>
<span class="nc" id="L53"> cryptoCofig.setCacheEnabled(Boolean.parseBoolean(enableCryptoCacheAttr.</span>
getAttributeValue().trim().toLowerCase()));
}
<span class="fc" id="L57"> Properties properties = new Properties();</span>
OMElement childElement;
OMAttribute name;
String value;
<span class="fc bfc" id="L63" title="All 2 branches covered."> for (Iterator iterator = element.getChildElements(); iterator.hasNext();) {</span>
/*
* In this senario we could have used
* element.getChildrenWithQName(USER); Unfortunately we can't do
* that due to a bug in this method. TODO Need to get it fixed
*/
<span class="fc" id="L70"> childElement = (OMElement) iterator.next();</span>
<span class="fc" id="L72"> QName prop = new QName(RampartConfig.NS, CryptoConfig.PROPERTY_LN);</span>
<span class="pc bpc" id="L74" title="1 of 2 branches missed."> if (prop.equals(childElement.getQName())) {</span>
<span class="fc" id="L75"> name = childElement.getAttribute(new QName(CryptoConfig.PROPERTY_NAME_ATTR));</span>
<span class="fc" id="L76"> value = childElement.getText();</span>
<span class="fc" id="L78"> properties.put(name.getAttributeValue(), value.trim());</span>
}
<span class="fc" id="L81"> }</span>
<span class="fc" id="L83"> cryptoCofig.setProp(properties);</span>
<span class="fc" id="L84"> return cryptoCofig;</span>
}
public QName[] getKnownElements() {
<span class="fc" id="L88"> return new QName[] {new QName(RampartConfig.NS, CryptoConfig.CRYPTO_LN)};</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.6.1.201212231917</span></div></body></html>