| <?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=""><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>TemplateSessionValidator.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">Apache Turbine</a> > <a href="index.source.html" class="el_package">org.apache.turbine.modules.actions.sessionvalidator</a> > <span class="el_source">TemplateSessionValidator.java</span></div><h1>TemplateSessionValidator.java</h1><pre class="source lang-java linenums">package org.apache.turbine.modules.actions.sessionvalidator; |
| |
| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you 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. |
| */ |
| |
| import org.apache.commons.lang3.StringUtils; |
| import org.apache.logging.log4j.Logger; |
| import org.apache.logging.log4j.LogManager; |
| import org.apache.turbine.Turbine; |
| import org.apache.turbine.om.security.User; |
| import org.apache.turbine.pipeline.PipelineData; |
| import org.apache.turbine.util.RunData; |
| |
| /** |
| * SessionValidator for use with the Template Service, the |
| * TemplateSessionValidator is virtually identical to the |
| * {@link TemplateSecureSessionValidator} except that it does not transfer to the |
| * login page when it detects a null user (or a user not logged in). |
| * |
| * <p>The Template Service requires a different Session Validator |
| * because of the way it handles screens. |
| * |
| * @see TemplateSecureSessionValidator |
| * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> |
| * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a> |
| * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> |
| * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> |
| * @version $Id$ |
| */ |
| <span class="nc" id="L46">public class TemplateSessionValidator</span> |
| extends SessionValidator |
| { |
| /** Logging */ |
| <span class="nc" id="L50"> private static Logger log = LogManager.getLogger(TemplateSessionValidator.class);</span> |
| |
| /** |
| * Execute the action. |
| * |
| * @param pipelineData Turbine information. |
| * @throws Exception The anonymous user could not be obtained |
| * from the security service |
| */ |
| @Override |
| public void doPerform(PipelineData pipelineData) throws Exception |
| { |
| <span class="nc" id="L62"> RunData data = pipelineData.getRunData();</span> |
| // Pull user from session. |
| <span class="nc" id="L64"> data.populate();</span> |
| |
| // The user may have not logged in, so create a "guest/anonymous" user. |
| <span class="nc bnc" id="L67" title="All 2 branches missed."> if (data.getUser() == null)</span> |
| { |
| <span class="nc" id="L69"> log.debug("Creating an anonymous user object!");</span> |
| <span class="nc" id="L70"> User anonymousUser = security.getAnonymousUser();</span> |
| <span class="nc" id="L71"> data.setUser(anonymousUser);</span> |
| <span class="nc" id="L72"> data.save();</span> |
| } |
| |
| // Make sure we have some way to return a response |
| <span class="nc bnc" id="L76" title="All 4 branches missed."> if (!data.hasScreen() && StringUtils.isEmpty(</span> |
| <span class="nc" id="L77"> data.getTemplateInfo().getScreenTemplate()))</span> |
| { |
| <span class="nc bnc" id="L79" title="All 2 branches missed."> if (StringUtils.isNotEmpty(templateHomepage))</span> |
| { |
| <span class="nc" id="L81"> data.getTemplateInfo().setScreenTemplate(templateHomepage);</span> |
| } |
| else |
| { |
| <span class="nc" id="L85"> data.setScreen(screenHomepage);</span> |
| } |
| } else { |
| <span class="nc" id="L88"> handleFormCounterToken(data, false);</span> |
| } |
| |
| // We do not want to allow both a screen and template parameter. |
| // The template parameter is dominant. |
| <span class="nc bnc" id="L93" title="All 2 branches missed."> if (data.getTemplateInfo().getScreenTemplate() != null)</span> |
| { |
| <span class="nc" id="L95"> data.setScreen(null);</span> |
| } |
| |
| // Comply with Turbine 4.0 standards |
| <span class="nc" id="L99"> pipelineData.get(Turbine.class).put(User.class, data.getUser());</span> |
| <span class="nc" id="L100"> }</span> |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html> |