📄 edithardtokenprofilejsphelper.java
字号:
/************************************************************************* * * * EJBCA: The OpenSource Certificate Authority * * * * This software is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * * License as published by the Free Software Foundation; either * * version 2.1 of the License, or any later version. * * * * See terms of license at gnu.org. * * * *************************************************************************/ package se.anatom.ejbca.webdist.hardtokeninterface;import java.io.*;import java.util.Iterator;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.apache.commons.fileupload.*;import se.anatom.ejbca.authorization.AuthorizationDeniedException;import se.anatom.ejbca.hardtoken.HardTokenProfileExistsException;import se.anatom.ejbca.hardtoken.hardtokenprofiles.EnhancedEIDProfile;import se.anatom.ejbca.hardtoken.hardtokenprofiles.HardTokenProfile;import se.anatom.ejbca.hardtoken.hardtokenprofiles.HardTokenProfileWithPINEnvelope;import se.anatom.ejbca.hardtoken.hardtokenprofiles.HardTokenProfileWithVisualLayout;import se.anatom.ejbca.hardtoken.hardtokenprofiles.IPINEnvelopeSettings;import se.anatom.ejbca.hardtoken.hardtokenprofiles.IVisualLayoutSettings;import se.anatom.ejbca.hardtoken.hardtokenprofiles.SwedishEIDProfile;import se.anatom.ejbca.webdist.webconfiguration.EjbcaWebBean;/** * Contains help methods used to parse a hard token profile jsp page requests. * * @author Philip Vendil * @version $Id: EditHardTokenProfileJSPHelper.java,v 1.3 2004/04/16 07:38:57 anatom Exp $ */public class EditHardTokenProfileJSPHelper { public static final String ACTION = "action"; public static final String ACTION_EDIT_HARDTOKENPROFILES = "edithardtokenprofiles"; public static final String ACTION_EDIT_HARDTOKENPROFILE = "edithardtokenprofile"; public static final String ACTION_UPLOADENVELOPETEMP = "uploadenvelopetemp"; public static final String ACTION_UPLOADVISUALTEMP = "uploadvisualtemp"; public static final String ACTION_CHANGE_PROFILETYPE = "changeprofiletype"; public static final String CHECKBOX_VALUE = HardTokenProfile.TRUE;// Used in profiles.jsp public static final String BUTTON_EDIT_HARDTOKENPROFILES = "buttonedithardtokenprofile"; public static final String BUTTON_DELETE_HARDTOKENPROFILES = "buttondeletehardtokenprofile"; public static final String BUTTON_ADD_HARDTOKENPROFILES = "buttonaddhardtokenprofile"; public static final String BUTTON_RENAME_HARDTOKENPROFILES = "buttonrenamehardtokenprofile"; public static final String BUTTON_CLONE_HARDTOKENPROFILES = "buttonclonehardtokenprofile"; public static final String SELECT_HARDTOKENPROFILES = "selecthardtokenprofile"; public static final String TEXTFIELD_HARDTOKENPROFILESNAME = "textfieldhardtokenprofilename"; public static final String HIDDEN_HARDTOKENPROFILENAME = "hiddenhardtokenprofilename"; // Buttons used in profile.jsp public static final String BUTTON_SAVE = "buttonsave"; public static final String BUTTON_CANCEL = "buttoncancel"; public static final String BUTTON_UPLOADENVELOPETEMP= "buttonuploadenvelopetemplate"; public static final String BUTTON_UPLOADVISUALTEMP = "buttonuploadvisualtemplate"; public static final String BUTTON_UPLOADFILE = "buttonuploadfile"; public static final String TYPE_SWEDISHEID = "typeswedisheid"; public static final String TYPE_ENCHANCEDEID = "typeenchancedeid"; public static final String TEXTFIELD_VISUALVALIDITY = "textfieldvisualvalidity"; public static final String TEXTFIELD_SNPREFIX = "textfieldsnprefix"; public static final String CHECKBOX_EREASBLE = "checkboxereasable"; public static final String CHECKBOX_KEYRECOVERABLE = "checkboxkeyrecoverable"; public static final String CHECKBOX_USEIDENTICALPINS= "useidenticalpins"; public static final String HIDDEN_HARDTOKENTYPE = "hiddenhardtokentype"; public static final String SELECT_HARDTOKENTYPE = "selecthardtokentype"; public static final String SELECT_CERTIFICATEPROFILE = "selectcertificateprofile"; public static final String SELECT_PINTYPE = "selectpintype"; public static final String SELECT_MINKEYLENGTH = "selectminkeylength"; public static final String SELECT_ENVELOPETYPE = "selectenvelopetype"; public static final String SELECT_NUMOFENVELOPECOPIES= "selectenvelopecopies"; public static final String SELECT_VISUALLAYOUTTYPE = "selectvisuallayouttype"; public static final String SELECT_NUMOFTOKENCOPIES = "selectnumoftokencopies"; public static final String FILE_TEMPLATE = "filetemplate"; public static final int UPLOADMODE_ENVELOPE = 0; public static final int UPLOADMODE_VISUAL = 1; /** Creates new LogInterfaceBean */ public EditHardTokenProfileJSPHelper(){ } // Public methods. /** * Method that initialized the bean. * * @param request is a reference to the http request. */ public void initialize(HttpServletRequest request, EjbcaWebBean ejbcawebbean, HardTokenInterfaceBean hardtokenbean) throws Exception{ if(!initialized){ this.ejbcawebbean = ejbcawebbean; this.hardtokenbean = hardtokenbean; initialized = true; issuperadministrator = false; try{ issuperadministrator = ejbcawebbean.isAuthorizedNoLog("/super_administrator"); }catch(AuthorizationDeniedException ade){} } } public String parseRequest(HttpServletRequest request) throws AuthorizationDeniedException{ String includefile = "hardtokenprofilespage.jsp"; String profile = null; HardTokenProfileDataHandler handler = hardtokenbean.getHardTokenProfileDataHandler(); String action = null; InputStream file = null; boolean errorrecievingfile = false; boolean buttoncancel = false; boolean buttonupload = false; String filename = null; if(FileUpload.isMultipartContent(request)){ try{ errorrecievingfile = true; DiskFileUpload upload = new DiskFileUpload(); upload.setSizeMax(500000); upload.setSizeThreshold(499999); List /* FileItem */ items = upload.parseRequest(request); Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { if(item.getFieldName().equals(ACTION)) action = item.getString(); if(item.getFieldName().equals(HIDDEN_HARDTOKENPROFILENAME)) profilename = item.getString(); if(item.getFieldName().equals(BUTTON_CANCEL)) buttoncancel = true; if(item.getFieldName().equals(BUTTON_UPLOADFILE)) buttonupload = true; }else{ file = item.getInputStream(); filename = item.getName(); errorrecievingfile = false; } } }catch(IOException e){ fileuploadfailed = true; includefile="hardtokenprofilepage.jsp"; }catch(FileUploadException e){ fileuploadfailed = true; includefile="hardtokenprofilepage.jsp"; } }else{ action = request.getParameter(ACTION); } if( action != null){ if( action.equals(ACTION_EDIT_HARDTOKENPROFILES)){ if( request.getParameter(BUTTON_EDIT_HARDTOKENPROFILES) != null){ // Display profilepage.jsp profile = request.getParameter(SELECT_HARDTOKENPROFILES); if(profile != null){ if(!profile.trim().equals("")){ includefile="hardtokenprofilepage.jsp"; this.profilename = profile; this.profiledata = handler.getHardTokenProfile(profilename); } else{ profile= null; } } if(profile == null){ includefile="hardtokenprofilespage.jsp"; } } if( request.getParameter(BUTTON_DELETE_HARDTOKENPROFILES) != null) { // Delete profile and display profilespage. profile = request.getParameter(SELECT_HARDTOKENPROFILES); if(profile != null){ if(!profile.trim().equals("")){ hardtokenprofiledeletefailed = handler.removeHardTokenProfile(profile); } } includefile="hardtokenprofilespage.jsp"; } if( request.getParameter(BUTTON_RENAME_HARDTOKENPROFILES) != null){ // Rename selected profile and display profilespage. String newhardtokenprofilename = request.getParameter(TEXTFIELD_HARDTOKENPROFILESNAME); String oldhardtokenprofilename = request.getParameter(SELECT_HARDTOKENPROFILES); if(oldhardtokenprofilename != null && newhardtokenprofilename != null){ if(!newhardtokenprofilename.trim().equals("") && !oldhardtokenprofilename.trim().equals("")){ try{ handler.renameHardTokenProfile(oldhardtokenprofilename.trim(),newhardtokenprofilename.trim()); }catch( HardTokenProfileExistsException e){ hardtokenprofileexists=true; } } } includefile="hardtokenprofilespage.jsp"; } if( request.getParameter(BUTTON_ADD_HARDTOKENPROFILES) != null){ // Add profile and display profilespage. profile = request.getParameter(TEXTFIELD_HARDTOKENPROFILESNAME); if(profile != null){ if(!profile.trim().equals("")){ try{ handler.addHardTokenProfile(profile.trim(), new SwedishEIDProfile()); }catch( HardTokenProfileExistsException e){ hardtokenprofileexists=true; } } } includefile="hardtokenprofilespage.jsp"; } if( request.getParameter(BUTTON_CLONE_HARDTOKENPROFILES) != null){ // clone profile and display profilespage. String newhardtokenprofilename = request.getParameter(TEXTFIELD_HARDTOKENPROFILESNAME); String oldhardtokenprofilename = request.getParameter(SELECT_HARDTOKENPROFILES); if(oldhardtokenprofilename != null && newhardtokenprofilename != null){ if(!newhardtokenprofilename.trim().equals("") && !oldhardtokenprofilename.trim().equals("")){ try{ handler.cloneHardTokenProfile(oldhardtokenprofilename.trim(),newhardtokenprofilename.trim()); }catch(HardTokenProfileExistsException e){ hardtokenprofileexists=true; } } } includefile="hardtokenprofilespage.jsp"; } } if( action.equals(ACTION_EDIT_HARDTOKENPROFILE)){ // Display edit access rules page. profile = request.getParameter(HIDDEN_HARDTOKENPROFILENAME);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -