Coverage Report - org.kuali.rice.ksb.security.admin.web.JavaSecurityManagementForm
 
Classes in this File Line Coverage Branch Coverage Complexity
JavaSecurityManagementForm
0%
0/27
0%
0/16
2.286
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.rice.ksb.security.admin.web;
 17  
 
 18  
 import java.security.KeyStoreException;
 19  
 
 20  
 import javax.servlet.http.HttpServletRequest;
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 import org.apache.struts.action.ActionErrors;
 24  
 import org.apache.struts.action.ActionForm;
 25  
 import org.apache.struts.action.ActionMapping;
 26  
 import org.apache.struts.action.ActionMessage;
 27  
 import org.kuali.rice.ksb.service.KSBServiceLocator;
 28  
 
 29  
 /**
 30  
  * Struts action form for the {@link JavaSecurityManagementAction} 
 31  
  * 
 32  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 33  
  *
 34  
  */
 35  0
 public class JavaSecurityManagementForm extends ActionForm {
 36  
 
 37  
     private static final long serialVersionUID = -46462912979586142L;
 38  
 
 39  
     private String alias;
 40  
     private String password;
 41  
     private String passwordVerify;
 42  
     
 43  
     /**
 44  
      * This method is used to check for completeness of the form as well as verification of the desired password
 45  
      */
 46  
     public ActionErrors validateGenerateClientKeystore(ActionMapping mapping, HttpServletRequest request) {
 47  0
         ActionErrors errors = new ActionErrors();
 48  
         // check that all data is filled in
 49  0
         if (StringUtils.isBlank(getAlias())) {
 50  0
             errors.add("property", new ActionMessage("Alias must have a valid value.",false));
 51  
         }
 52  0
         if (StringUtils.isBlank(getPassword()) || StringUtils.isBlank(getPasswordVerify()) ) {
 53  0
             errors.add("property", new ActionMessage("Password must have a valid value in both fields.",false));
 54  
         }
 55  0
         if (errors.isEmpty()) {
 56  
             // if password and passwordVerify are not equal error out
 57  0
             if (!StringUtils.equals(getPassword(), getPasswordVerify())) {
 58  0
                 errors.add("property", new ActionMessage("Passwords do not match.",false));
 59  
             }
 60  
         }
 61  0
         if (errors.isEmpty()) {
 62  
             try {
 63  0
                 if (KSBServiceLocator.getJavaSecurityManagementService().isAliasInKeystore(getAlias())) {
 64  0
                     errors.add("property", new ActionMessage("Alias '" + getAlias() + "' already exists in keystore.",false));
 65  
                 }
 66  0
             } catch (KeyStoreException e) {
 67  0
                 errors.add("property", new ActionMessage("Could not check keystore file for alias '" + getAlias(),false));
 68  0
             }
 69  
         }
 70  0
         return errors;
 71  
     }
 72  
 
 73  
     public String getAlias() {
 74  0
         return this.alias;
 75  
     }
 76  
     public void setAlias(String alias) {
 77  0
         if (alias == null) {
 78  0
             this.alias = null;
 79  
         } else {
 80  0
             this.alias = alias.trim();
 81  
         }
 82  0
     }
 83  
     public String getPassword() {
 84  0
         return this.password;
 85  
     }
 86  
     public void setPassword(String password) {
 87  0
         this.password = password;
 88  0
     }
 89  
     public String getPasswordVerify() {
 90  0
         return this.passwordVerify;
 91  
     }
 92  
     public void setPasswordVerify(String passwordVerify) {
 93  0
         this.passwordVerify = passwordVerify;
 94  0
     }
 95  
 
 96  
 }