| <?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>TokenRequestDispatcher.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> > <a href="index.html" class="el_package">org.apache.rahas</a> > <span class="el_source">TokenRequestDispatcher.java</span></div><h1>TokenRequestDispatcher.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.rahas; |
| |
| import org.apache.axiom.om.OMElement; |
| import org.apache.axiom.soap.SOAPEnvelope; |
| import org.apache.axis2.context.MessageContext; |
| import org.apache.commons.logging.Log; |
| import org.apache.commons.logging.LogFactory; |
| |
| public class TokenRequestDispatcher { |
| |
| private TokenRequestDispatcherConfig config; |
| |
| <span class="fc" id="L28"> private static Log mlog = LogFactory.getLog("org.apache.rampart.messages");</span> |
| <span class="fc" id="L29"> private static Log log = LogFactory.getLog(TokenRequestDispatcher.class.getName());</span> |
| |
| <span class="fc" id="L31"> public TokenRequestDispatcher(TokenRequestDispatcherConfig config) throws TrustException {</span> |
| <span class="fc" id="L32"> this.config = config;</span> |
| <span class="fc" id="L33"> }</span> |
| |
| public TokenRequestDispatcher(OMElement config) throws TrustException { |
| <span class="fc" id="L36"> this(TokenRequestDispatcherConfig.load(config));</span> |
| <span class="fc" id="L37"> }</span> |
| |
| public TokenRequestDispatcher(String configFilePath) throws TrustException { |
| <span class="nc" id="L40"> this(TokenRequestDispatcherConfig.load(configFilePath));</span> |
| <span class="nc" id="L41"> }</span> |
| |
| /** |
| * Processes the incoming request and returns a SOAPEnvelope |
| * @param inMsgCtx |
| * @return The response SOAPEnvelope |
| * @throws TrustException |
| */ |
| public SOAPEnvelope handle(MessageContext inMsgCtx, |
| MessageContext outMsgCtx) throws TrustException { |
| |
| <span class="pc bpc" id="L52" title="1 of 2 branches missed."> if(mlog.isDebugEnabled()){</span> |
| <span class="nc" id="L53"> mlog.debug("*********************** TokenRequestDispatcher received \n"+inMsgCtx.getEnvelope());</span> |
| } |
| <span class="fc" id="L55"> RahasData data = new RahasData(inMsgCtx);</span> |
| |
| <span class="fc" id="L57"> String reqType = data.getRequestType();</span> |
| <span class="fc" id="L58"> String tokenType = data.getTokenType();</span> |
| <span class="fc bfc" id="L59" title="All 4 branches covered."> if ((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_ISSUE).equals(reqType) ||</span> |
| (RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_ISSUE).equals(reqType)) { |
| <span class="fc" id="L61"> log.debug("issue");</span> |
| TokenIssuer issuer; |
| <span class="pc bpc" id="L63" title="2 of 4 branches missed."> if (tokenType == null || tokenType.trim().length() == 0) {</span> |
| <span class="nc" id="L64"> issuer = config.getDefaultIssuerInstace();</span> |
| } else { |
| <span class="fc" id="L66"> issuer = config.getIssuer(tokenType);</span> |
| } |
| |
| <span class="fc" id="L69"> SOAPEnvelope response = issuer.issue(data);</span> |
| |
| //set the response wsa/soap action in the out message context |
| <span class="fc" id="L72"> outMsgCtx.getOptions().setAction(issuer.getResponseAction(data));</span> |
| |
| <span class="pc bpc" id="L74" title="1 of 2 branches missed."> if(mlog.isDebugEnabled()){</span> |
| <span class="nc" id="L75"> mlog.debug("*********************** TokenRequestDispatcher sent out \n"+response);</span> |
| } |
| |
| <span class="fc" id="L78"> return response;</span> |
| <span class="pc bpc" id="L79" title="2 of 4 branches missed."> } else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_VALIDATE).equals(reqType) ||</span> |
| (RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_VALIDATE).equals(reqType)) { |
| <span class="nc" id="L81"> log.debug("validate");</span> |
| |
| TokenValidator validator; |
| <span class="nc bnc" id="L84" title="All 4 branches missed."> if (tokenType == null || tokenType.trim().length() == 0) {</span> |
| <span class="nc" id="L85"> validator = config.getDefaultValidatorInstance();</span> |
| } else { |
| <span class="nc" id="L87"> validator = config.getValidator(tokenType);</span> |
| } |
| |
| <span class="nc" id="L90"> SOAPEnvelope response = validator.validate(data);</span> |
| |
| <span class="nc" id="L92"> outMsgCtx.getOptions().setAction(</span> |
| TrustUtil.getActionValue(data.getVersion(), |
| RahasConstants.RSTR_ACTION_VALIDATE)); |
| |
| <span class="nc" id="L96"> return response;</span> |
| |
| |
| |
| <span class="pc bpc" id="L100" title="2 of 4 branches missed."> } else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_RENEW).equals(reqType) ||</span> |
| (RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_RENEW).equals(reqType)) { |
| <span class="nc" id="L102"> log.debug("renew");</span> |
| |
| TokenRenewer renewer; |
| <span class="nc bnc" id="L105" title="All 4 branches missed."> if (tokenType == null || tokenType.trim().length() == 0) {</span> |
| <span class="nc" id="L106"> renewer = config.getDefaultRenewerInstance();</span> |
| } else { |
| <span class="nc" id="L108"> renewer = config.getRenewer(tokenType); </span> |
| } |
| |
| <span class="nc" id="L111"> SOAPEnvelope response = renewer.renew(data);</span> |
| |
| <span class="nc" id="L113"> outMsgCtx.getOptions().setAction(</span> |
| TrustUtil.getActionValue(data.getVersion(), |
| RahasConstants.RSTR_ACTION_RENEW)); |
| |
| <span class="nc" id="L117"> return response; </span> |
| |
| <span class="pc bpc" id="L119" title="1 of 4 branches missed."> } else if((RahasConstants.WST_NS_05_02 + RahasConstants.REQ_TYPE_CANCEL).equals(reqType) ||</span> |
| (RahasConstants.WST_NS_05_12 + RahasConstants.REQ_TYPE_CANCEL).equals(reqType)) { |
| <span class="fc" id="L121"> log.debug("cancel");</span> |
| <span class="fc" id="L122"> TokenCanceler canceler = config.getDefaultCancelerInstance();</span> |
| <span class="fc" id="L123"> SOAPEnvelope response = canceler.cancel(data);</span> |
| |
| //set the response wsa/soap action in the out message context |
| <span class="fc" id="L126"> outMsgCtx.getOptions().setAction(canceler.getResponseAction(data));</span> |
| <span class="fc" id="L127"> return response;</span> |
| } else { |
| <span class="nc" id="L129"> throw new TrustException(TrustException.INVALID_REQUEST);</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> |