View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.web.struts;
17  
18  import javax.servlet.http.HttpServletRequest;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.kuali.rice.kns.web.struts.form.KualiForm;
22  import org.kuali.rice.krad.util.KRADConstants;
23  
24  public class KualiBatchFileAdminForm extends KualiForm {
25      private String filePath;
26  
27      /**
28       * @see org.kuali.rice.kns.web.struts.form.KualiForm#populate(javax.servlet.http.HttpServletRequest)
29       */
30      @Override
31      public void populate(HttpServletRequest request) {
32          super.populate(request);
33          
34          if (StringUtils.isBlank(getFilePath())&& 
35                  StringUtils.isNotBlank(request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME)) &&
36                  StringUtils.isNotBlank(request.getParameter(KRADConstants.QUESTION_CONTEXT))) {
37              setFilePath(request.getParameter(KRADConstants.QUESTION_CONTEXT));
38          }
39          
40          if (filePath != null && filePath.matches(".*\\.\\.[/\\\\].*")) {
41              throw new RuntimeException("Cannot access parent directory");
42          }
43      }
44  
45      public String getFilePath() {
46          return filePath;
47      }
48  
49      public void setFilePath(String filePath) {
50          this.filePath = filePath;
51      }
52  }