| <?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>CryptoConfig.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="info"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Coverage Report</a> > <a href="index.source.html" class="el_package">org.apache.rampart.policy.model</a> > <span class="el_source">CryptoConfig.java</span></div><h1>CryptoConfig.java</h1><pre class="source lang-java linenums">/* |
| * Copyright 2004,2005 The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * 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 "AS IS" 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.model; |
| |
| import org.apache.neethi.Assertion; |
| import org.apache.neethi.Constants; |
| import org.apache.neethi.PolicyComponent; |
| |
| import javax.xml.namespace.QName; |
| import javax.xml.stream.XMLStreamException; |
| import javax.xml.stream.XMLStreamWriter; |
| |
| import java.util.Iterator; |
| import java.util.Properties; |
| |
| /** |
| * Policy model bean to capture crypto information. |
| * |
| * Example: |
| <pre> |
| &lt;ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin"&gt; |
| &lt;ramp:property name="keystoreType"&gt;JKS&lt;/ramp:property&gt; |
| &lt;ramp:property name="keystoreFile"&gt;/path/to/file.jks&lt;/ramp:property&gt; |
| &lt;ramp:property name="keystorePassword"&gt;password&lt;/ramp:property&gt; |
| &lt;/ramp:crypto&gt; |
| </pre> |
| */ |
| <span class="fc" id="L42">public class CryptoConfig implements Assertion {</span> |
| |
| public final static String CRYPTO_LN = "crypto"; |
| public final static String PROVIDER_ATTR = "provider"; |
| public final static String PROPERTY_LN = "property"; |
| public final static String PROPERTY_NAME_ATTR = "name"; |
| public final static String CRYPTO_KEY_ATTR = "cryptoKey"; |
| public final static String CACHE_REFRESH_INTVL = "cacheRefreshInterval"; |
| public static final String CACHE_ENABLED = "enableCryptoCaching"; |
| |
| private Properties prop; |
| |
| <span class="fc" id="L54"> private boolean cacheEnabled = true;</span> |
| |
| private String provider; |
| private String cryptoKey; |
| private String cacheRefreshInterval; |
| |
| public String getCryptoKey() { |
| <span class="fc" id="L61"> return cryptoKey;</span> |
| } |
| |
| public void setCryptoKey(String cryptoKey) { |
| <span class="nc" id="L65"> this.cryptoKey = cryptoKey;</span> |
| <span class="nc" id="L66"> }</span> |
| |
| public String getCacheRefreshInterval() { |
| <span class="nc" id="L69"> return cacheRefreshInterval;</span> |
| } |
| |
| public void setCacheRefreshInterval(String cacheRefreshInterval) { |
| <span class="nc" id="L73"> this.cacheRefreshInterval = cacheRefreshInterval;</span> |
| <span class="nc" id="L74"> }</span> |
| |
| public Properties getProp() { |
| <span class="fc" id="L77"> return prop;</span> |
| } |
| |
| public void setProp(Properties prop) { |
| <span class="fc" id="L81"> this.prop = prop;</span> |
| <span class="fc" id="L82"> }</span> |
| |
| public String getProvider() { |
| <span class="fc" id="L85"> return provider;</span> |
| } |
| |
| public void setProvider(String provider) { |
| <span class="fc" id="L89"> this.provider = provider;</span> |
| <span class="fc" id="L90"> }</span> |
| |
| public QName getName() { |
| <span class="fc" id="L93"> return new QName(RampartConfig.NS, CRYPTO_LN);</span> |
| } |
| |
| public boolean isOptional() { |
| // TODO TODO |
| <span class="nc" id="L98"> throw new UnsupportedOperationException("TODO");</span> |
| } |
| |
| public boolean isIgnorable() { |
| // TODO TODO |
| <span class="nc" id="L103"> throw new UnsupportedOperationException("TODO");</span> |
| } |
| |
| public PolicyComponent normalize() { |
| // TODO TODO |
| <span class="nc" id="L108"> throw new UnsupportedOperationException("TODO");</span> |
| } |
| |
| public boolean isCacheEnabled() { |
| <span class="fc" id="L112"> return cacheEnabled;</span> |
| } |
| |
| public void setCacheEnabled(boolean cacheEnabled) { |
| <span class="nc" id="L116"> this.cacheEnabled = cacheEnabled;</span> |
| <span class="nc" id="L117"> }</span> |
| |
| public void serialize(XMLStreamWriter writer) throws XMLStreamException { |
| <span class="nc" id="L120"> String prefix = writer.getPrefix(RampartConfig.NS);</span> |
| |
| <span class="nc bnc" id="L122" title="All 2 branches missed."> if (prefix == null) {</span> |
| <span class="nc" id="L123"> prefix = RampartConfig.NS;</span> |
| <span class="nc" id="L124"> writer.setPrefix(prefix, RampartConfig.NS);</span> |
| } |
| |
| <span class="nc" id="L127"> writer.writeStartElement(prefix, CRYPTO_LN, RampartConfig.NS);</span> |
| |
| <span class="nc bnc" id="L129" title="All 2 branches missed."> if (getProvider() != null) {</span> |
| <span class="nc" id="L130"> writer.writeAttribute(PROVIDER_ATTR, getProvider());</span> |
| } |
| |
| <span class="nc bnc" id="L133" title="All 2 branches missed."> if(getCryptoKey() != null){</span> |
| <span class="nc" id="L134"> writer.writeAttribute(CRYPTO_KEY_ATTR, getCryptoKey());</span> |
| } |
| |
| <span class="nc bnc" id="L137" title="All 2 branches missed."> if(getCacheRefreshInterval() != null){</span> |
| <span class="nc" id="L138"> writer.writeAttribute(CACHE_REFRESH_INTVL, getCacheRefreshInterval()); </span> |
| } |
| |
| <span class="nc bnc" id="L141" title="All 2 branches missed."> if(!isCacheEnabled()){</span> |
| <span class="nc" id="L142"> writer.writeAttribute(CACHE_ENABLED, Boolean.toString(isCacheEnabled()));</span> |
| } |
| |
| String key; |
| String value; |
| |
| <span class="nc bnc" id="L148" title="All 2 branches missed."> for (Iterator iterator = prop.keySet().iterator(); iterator.hasNext();) {</span> |
| <span class="nc" id="L149"> key = (String) iterator.next();</span> |
| <span class="nc" id="L150"> value = prop.getProperty(key);</span> |
| <span class="nc" id="L151"> writer.writeStartElement(RampartConfig.NS, PROPERTY_LN);</span> |
| |
| <span class="nc" id="L153"> writer.writeAttribute("name", key);</span> |
| |
| <span class="nc" id="L155"> writer.writeCharacters(value);</span> |
| <span class="nc" id="L156"> writer.writeEndElement();</span> |
| } |
| |
| <span class="nc" id="L159"> writer.writeEndElement();</span> |
| <span class="nc" id="L160"> }</span> |
| |
| public boolean equal(PolicyComponent policyComponent) { |
| <span class="nc" id="L163"> throw new UnsupportedOperationException();</span> |
| } |
| |
| public short getType() { |
| <span class="nc" id="L167"> return Constants.TYPE_ASSERTION;</span> |
| } |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.5.201505241946</span></div></body></html> |