blob: 44f824f43bff35ade42859909ed9fbdf667ab81c [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>WSDoAllHandler.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.handler</a> &gt; <span class="el_source">WSDoAllHandler.java</span></div><h1>WSDoAllHandler.java</h1><pre class="source lang-java linenums">/*
* Copyright 2004,2005 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.handler;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.HandlerDescription;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.Handler;
import org.apache.rampart.util.Axis2Util;
import org.apache.ws.security.handler.WSHandler;
/**
* Class WSDoAllHandler
*/
public abstract class WSDoAllHandler extends WSHandler implements Handler {
/**
* Field EMPTY_HANDLER_METADATA
*/
<span class="fc" id="L35"> private static HandlerDescription EMPTY_HANDLER_METADATA =</span>
new HandlerDescription(&quot;default Handler&quot;);
private final static String WSS_PASSWORD = &quot;password&quot;;
private final static String WSS_USERNAME = &quot;username&quot;;
/**
* Field handlerDesc
*/
protected HandlerDescription handlerDesc;
/**
* In Axis2, the user cannot set inflow and outflow parameters.
* Therefore, we need to map the Axis2 specific inflow and outflow
* parameters to WSS4J params,
* &lt;p/&gt;
* Knowledge of inhandler and out handler is used to get the mapped value.
*/
protected boolean inHandler;
/**
* Constructor AbstractHandler.
*/
<span class="fc" id="L59"> public WSDoAllHandler() {</span>
<span class="fc" id="L60"> handlerDesc = EMPTY_HANDLER_METADATA;</span>
<span class="fc" id="L61"> }</span>
public abstract void processMessage(MessageContext msgContext) throws AxisFault;
/* (non-Javadoc)
* @see org.apache.axis2.engine.Handler#invoke(org.apache.axis2.context.MessageContext)
*/
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
//If the security module is not engaged for this service
//do not do any processing
<span class="fc bfc" id="L71" title="All 2 branches covered."> if (msgContext.isEngaged(WSSHandlerConstants.SECURITY_MODULE_NAME)) {</span>
<span class="fc" id="L72"> this.processMessage(msgContext);</span>
}
<span class="fc" id="L74"> return InvocationResponse.CONTINUE; </span>
}
public void flowComplete(MessageContext msgContext)
{
<span class="fc" id="L79"> }</span>
/**
* Method getName.
*
* @return Returns name.
*/
public String getName() {
<span class="fc" id="L87"> return handlerDesc.getName();</span>
}
/**
* Method cleanup.
*/
public void cleanup() {
<span class="nc" id="L94"> }</span>
/**
* Method getParameter.
*
* @param name
* @return Returns parameter.
*/
public Parameter getParameter(String name) {
<span class="nc" id="L103"> return handlerDesc.getParameter(name);</span>
}
/**
* Method init.
*
* @param handlerdesc
*/
public void init(HandlerDescription handlerdesc) {
<span class="fc" id="L112"> this.handlerDesc = handlerdesc;</span>
<span class="fc" id="L113"> }</span>
/**
* Gets the handler description.
*
* @return Returns handler description.
*/
public HandlerDescription getHandlerDesc() {
<span class="fc" id="L121"> return handlerDesc;</span>
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
<span class="nc" id="L128"> String name = this.getName();</span>
<span class="nc bnc" id="L129" title="All 2 branches missed."> return (name != null) ? name : &quot;&quot;;</span>
}
public Object getProperty(Object msgContext, String axisKey) {
<span class="fc" id="L135"> int repetition = getCurrentRepetition(msgContext);</span>
<span class="fc" id="L137"> String key = Axis2Util.getKey(axisKey, inHandler, repetition);</span>
<span class="fc" id="L138"> Object property = ((MessageContext) msgContext).getProperty(key);</span>
<span class="fc bfc" id="L139" title="All 2 branches covered."> if (property == null) {</span>
//Try the description hierarchy
<span class="fc" id="L141"> Parameter parameter = ((MessageContext) msgContext).getParameter(key);</span>
<span class="fc bfc" id="L142" title="All 2 branches covered."> if (parameter != null) {</span>
<span class="fc" id="L143"> property = parameter.getValue();</span>
}
}
<span class="fc" id="L146"> return property;</span>
}
/**
* Returns the repetition number from the message context
*
* @param msgContext
* @return Returns int.
*/
protected int getCurrentRepetition(Object msgContext) {
//get the repetition from the message context
<span class="fc" id="L157"> int repetition = 0;</span>
<span class="fc bfc" id="L158" title="All 2 branches covered."> if (!inHandler) {//We only need to repeat the out handler</span>
<span class="fc" id="L159"> Integer count = (Integer) ((MessageContext) msgContext).getProperty(WSSHandlerConstants.CURRENT_REPETITON);</span>
<span class="fc bfc" id="L160" title="All 2 branches covered."> if (count != null) { //When we are repeating the handler</span>
<span class="fc" id="L161"> repetition = count.intValue();</span>
}
}
<span class="fc" id="L164"> return repetition;</span>
}
public String getPassword(Object msgContext) {
<span class="nc" id="L168"> return (String) ((MessageContext) msgContext).getProperty(WSS_PASSWORD);</span>
}
public void setPassword(Object msgContext, String password) {
<span class="nc" id="L172"> ((MessageContext) msgContext).setProperty(WSS_PASSWORD, password);</span>
<span class="nc" id="L173"> }</span>
public String getUsername(Object msgContext) {
<span class="nc" id="L176"> return (String) ((MessageContext) msgContext).getProperty(WSS_USERNAME);</span>
}
public void setUsername(Object msgContext, String username) {
<span class="nc" id="L180"> ((MessageContext) msgContext).setProperty(WSS_USERNAME, username);</span>
<span class="nc" id="L181"> }</span>
/**
* Gets option. Extracts the configuration values from the service.xml
* and/or axis2.xml. Values set in the service.xml takes priority over
* values of the axis2.xml
*/
public Object getOption(String axisKey) {
<span class="fc" id="L189"> Parameter parameter = this.handlerDesc.getParameter(axisKey);</span>
<span class="pc bpc" id="L190" title="1 of 2 branches missed."> return (parameter == null) ? null : parameter.getValue();</span>
}
public void setProperty(Object msgContext, String key, Object value) {
<span class="fc" id="L194"> ((MessageContext) msgContext).setProperty(key, value);</span>
<span class="fc" id="L195"> }</span>
/**
* Overrides the class loader used to load the PW callback class.
*
* @param msgCtx MessageContext
* @return Returns class loader.
*/
public java.lang.ClassLoader getClassLoader(Object msgCtx) {
try {
<span class="fc" id="L205"> return ((MessageContext) msgCtx).getAxisService().getClassLoader();</span>
<span class="nc" id="L206"> } catch (Throwable t) {</span>
<span class="nc" id="L207"> return super.getClassLoader(msgCtx);</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>