1 package org.apache.turbine.modules.actions; 2 3 56 57 import org.apache.turbine.Turbine; 58 import org.apache.turbine.RunData; 59 import org.apache.fulcrum.security.TurbineSecurity; 60 61 75 public class TemplateSessionValidator 76 extends SessionValidator 77 { 78 83 protected String COUNTER = "_session_access_counter"; 84 85 91 public void doPerform(RunData data) 92 throws Exception 93 { 94 data.populate(); 96 97 if ( data.getUser() == null ) 99 { 100 data.setUser(TurbineSecurity.getAnonymousUser()); 102 data.save(); 103 } 104 105 if (!data.hasTarget()) 107 { 108 setTarget(data); 109 } 110 else if (data.getParameters().containsKey(COUNTER) ) 111 { 112 processCounter(data); 113 } 114 } 115 116 protected void setTarget(RunData data) 117 { 118 String target = data.getParameters().getString("template"); 119 120 if (target != null) 121 { 122 data.setTarget(target); 123 } 124 else 125 { 126 data.setTarget(Turbine.getConfiguration().getString( 127 Turbine.TEMPLATE_HOMEPAGE)); 128 } 129 } 130 131 protected void processCounter(RunData data) 132 { 133 if (data.getParameters().getInt(COUNTER) < 135 (((Integer )data.getUser().getTemp(COUNTER)).intValue() - 1) ) 136 { 137 if (data.hasTarget()) 138 { 139 data.getUser().setTemp( "prev_template", data.getTarget()); 140 141 data.setTarget(Turbine.getConfiguration().getString( 142 Turbine.TEMPLATE_INVALID_STATE)); 143 } 144 data.getUser().setTemp( "prev_parameters", data.getParameters() ); 145 data.setAction( "" ); 146 } 147 } 148 } 149 | Popular Tags |