⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 endentityprofile.java

📁 一套JAVA的CA证书签发系统.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/************************************************************************* *                                                                       * *  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.ra.raadmin;import java.util.HashMap;import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.Collection;import java.util.Iterator;import org.apache.log4j.Logger;import se.anatom.ejbca.SecConst;import se.anatom.ejbca.util.UpgradeableDataHashMap;import se.anatom.ejbca.util.passgen.PasswordGeneratorFactory;/** * The model representation of an end entity profile, used in in the ra module * of ejbca web interface. * * @author  Philip Vendil * @version $Id: EndEntityProfile.java,v 1.26.2.1 2004/06/22 11:18:43 herrvendil Exp $ */public class EndEntityProfile extends UpgradeableDataHashMap implements java.io.Serializable, Cloneable {    private static Logger log = Logger.getLogger(EndEntityProfile.class);    public static final float LATEST_VERSION = 4;    // Public constants    // Type of data constants.    public static final int VALUE      = 0;    public static final int USE        = 1;    public static final int ISREQUIRED = 2;    public static final int MODIFYABLE = 3;    // Field constants.    public static final int USERNAME           = 0;    public static final int PASSWORD           = 1;    public static final int CLEARTEXTPASSWORD  = 2;    public static final int OLDDNE             = 3;    public static final int UID                = 4;    public static final int COMMONNAME         = 5;    public static final int SN                 = 6;    public static final int GIVENNAME          = 7;    public static final int INITIALS           = 8;    public static final int SURNAME            = 9;    public static final int TITLE              = 10;    public static final int ORGANIZATIONUNIT   = 11;    public static final int ORGANIZATION       = 12;    public static final int LOCALE             = 13;    public static final int STATE              = 14;    public static final int DOMAINCOMPONENT    = 15;    public static final int COUNTRY            = 16;    public static final int RFC822NAME         = 17;    public static final int DNSNAME            = 18;    public static final int IPADDRESS          = 19;    public static final int OTHERNAME          = 20;    public static final int UNIFORMRESOURCEID  = 21;    public static final int X400ADDRESS        = 22;    public static final int DIRECTORYNAME      = 23;    public static final int EDIPARTNAME        = 24;    public static final int REGISTEREDID       = 25;    public static final int EMAIL              = 26;    public static final int ADMINISTRATOR      = 27;    public static final int KEYRECOVERABLE     = 28;    public static final int DEFAULTCERTPROFILE = 29;    public static final int AVAILCERTPROFILES  = 30;    public static final int DEFKEYSTORE        = 31;    public static final int AVAILKEYSTORE      = 32;    public static final int DEFAULTTOKENISSUER = 33;    public static final int AVAILTOKENISSUER   = 34;    public static final int SENDNOTIFICATION   = 35;    public static final int UPN                = 36;    public static final int DEFAULTCA          = 37;    public static final int AVAILCAS           = 38;        public static final int UNSTRUCTUREDADDRESS = 39;    public static final int UNSTRUCTUREDNAME    = 40;    public static final int GUID                = 41;            public static final int NUMBEROFPARAMETERS = 42;    public static final String SPLITCHAR       = ";";    public static final String TRUE  = "true";    public static final String FALSE = "false";    // Constants used with field ordering    public static final int FIELDTYPE = 0;    public static final int NUMBER    = 1;    // Public methods.    /** Creates a new instance of EndEntity Profile */    public EndEntityProfile() {      super();      // Set default required fields.      init(false);    }    /** Creates a default empty end entity profile with all standard fields added to it. */    public  EndEntityProfile(boolean emptyprofile){      super();      init(emptyprofile);    }    private void init(boolean emptyprofile){      if(emptyprofile){        // initialize profile data        ArrayList numberoffields = new ArrayList(NUMBEROFPARAMETERS);        for(int i =0; i < NUMBEROFPARAMETERS; i++){          numberoffields.add(new Integer(0));        }        data.put(NUMBERARRAY,numberoffields);        data.put(SUBJECTDNFIELDORDER,new ArrayList());        data.put(SUBJECTALTNAMEFIELDORDER,new ArrayList());        for(int i=0; i < NUMBEROFPARAMETERS; i++){          if(i != SENDNOTIFICATION &&          	 i != OTHERNAME &&			 i != X400ADDRESS &&			 i != EDIPARTNAME &&			 i != REGISTEREDID &&			 i != DIRECTORYNAME ){	             addField(i);             setValue(i,0,"");             setRequired(i,0,false);             setUse(i,0,true);             setModifyable(i,0,true);          }          }        setRequired(USERNAME,0,true);        setRequired(PASSWORD,0,true);        setRequired(COMMONNAME,0,true);        setRequired(DEFAULTCERTPROFILE,0,true);        setRequired(AVAILCERTPROFILES,0,true);        setRequired(DEFKEYSTORE,0,true);        setRequired(AVAILKEYSTORE,0,true);        setRequired(DEFAULTCA,0,true);        setRequired(AVAILCAS,0,true);        setValue(DEFAULTCERTPROFILE,0,"1");        setValue(AVAILCERTPROFILES,0,"1");        setValue(DEFKEYSTORE,0, "" + SecConst.TOKEN_SOFT_BROWSERGEN);        setValue(AVAILKEYSTORE,0, SecConst.TOKEN_SOFT_BROWSERGEN + ";" + SecConst.TOKEN_SOFT_P12 +  ";" + SecConst.TOKEN_SOFT_JKS + ";" + SecConst.TOKEN_SOFT_PEM);        setValue(AVAILCAS,0, Integer.toString(SecConst.ALLCAS));        // Do not use hard token issuers by default.        setUse(AVAILTOKENISSUER, 0, false);      }else{         // initialize profile data         ArrayList numberoffields = new ArrayList(NUMBEROFPARAMETERS);         for(int i =0; i < NUMBEROFPARAMETERS; i++){           numberoffields.add(new Integer(0));         }         data.put(NUMBERARRAY,numberoffields);         data.put(SUBJECTDNFIELDORDER,new ArrayList());         data.put(SUBJECTALTNAMEFIELDORDER,new ArrayList());         addField(USERNAME);         addField(PASSWORD);         addField(COMMONNAME);         addField(EMAIL);         addField(DEFAULTCERTPROFILE);         addField(AVAILCERTPROFILES);         addField(DEFKEYSTORE);         addField(AVAILKEYSTORE);         addField(DEFAULTTOKENISSUER);         addField(AVAILTOKENISSUER);         addField(AVAILCAS);         addField(DEFAULTCA);                           setRequired(USERNAME,0,true);         setRequired(PASSWORD,0,true);         setRequired(COMMONNAME,0,true);         setRequired(DEFAULTCERTPROFILE,0,true);         setRequired(AVAILCERTPROFILES,0,true);         setRequired(DEFKEYSTORE,0,true);         setRequired(AVAILKEYSTORE,0,true);         setRequired(DEFAULTCA,0,true);         setRequired(AVAILCAS,0,true);                  setValue(DEFAULTCERTPROFILE,0,"1");         setValue(AVAILCERTPROFILES,0,"1;2;3");         setValue(DEFKEYSTORE,0, "" + SecConst.TOKEN_SOFT_BROWSERGEN);         setValue(AVAILKEYSTORE,0, SecConst.TOKEN_SOFT_BROWSERGEN + ";" + SecConst.TOKEN_SOFT_P12 +  ";" + SecConst.TOKEN_SOFT_JKS + ";" + SecConst.TOKEN_SOFT_PEM);         // Do not use hard token issuers by default.         setUse(AVAILTOKENISSUER, 0, false);      }    }    /**     * Function that adds a field to the profile.     *     * @param paramter is the field and one of the field constants.     */    public void addField(int parameter){      int size =  getNumberOfField(parameter);      setValue(parameter,size,"");      setRequired(parameter,size,false);      setUse(parameter,size,true);      setModifyable(parameter,size,true);      if(parameter >= OLDDNE && parameter <= COUNTRY || parameter == UNSTRUCTUREDADDRESS || parameter == UNSTRUCTUREDNAME){        ArrayList fieldorder = (ArrayList) data.get(SUBJECTDNFIELDORDER);        fieldorder.add(new Integer((NUMBERBOUNDRARY*parameter) + size));        Collections.sort(fieldorder);      }      if((parameter >= RFC822NAME && parameter <= REGISTEREDID) || parameter == UPN  || parameter == GUID){        ArrayList fieldorder = (ArrayList) data.get(SUBJECTALTNAMEFIELDORDER);        fieldorder.add(new Integer((NUMBERBOUNDRARY*parameter) + size));      }      incrementFieldnumber(parameter);    }    /**     * Function that removes a field from the end entity profile.     *     * @param parameter is the field to remove.     * @param number is the number of field.     */    public void removeField(int parameter, int number){      // Remove field and move all fileds above.      int size =  getNumberOfField(parameter);      if(size>0){        for(int n = number; n < size-1; n++){          setValue(parameter,n,getValue(parameter,n+1));          setRequired(parameter,n,isRequired(parameter,n+1));          setUse(parameter,n,getUse(parameter,n+1));          setModifyable(parameter,n,isModifyable(parameter,n+1));        }        // Remove from order list.        if(parameter >= OLDDNE && parameter <= COUNTRY || parameter == UNSTRUCTUREDADDRESS || parameter == UNSTRUCTUREDNAME){          ArrayList fieldorder = (ArrayList) data.get(SUBJECTDNFIELDORDER);          int value = (NUMBERBOUNDRARY*parameter) + number;          for(int i=0; i < fieldorder.size(); i++){             if( value ==  ((Integer) fieldorder.get(i)).intValue()){                fieldorder.remove(i);                break;             }          }        }        if((parameter >= RFC822NAME && parameter <= REGISTEREDID) || parameter == UPN  || parameter == GUID){          ArrayList fieldorder = (ArrayList) data.get(SUBJECTALTNAMEFIELDORDER);          int value = (NUMBERBOUNDRARY*parameter) + number;          for(int i=0; i < fieldorder.size(); i++){             if( value ==  ((Integer) fieldorder.get(i)).intValue()){                fieldorder.remove(i);                break;             }          }        }        data.remove(new Integer((VALUE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter));        data.remove(new Integer((USE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter));        data.remove(new Integer((ISREQUIRED*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter));        data.remove(new Integer((MODIFYABLE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter));        decrementFieldnumber(parameter);      }    }    /**     * Function that returns the number of one kind of field.     *     */    public int getNumberOfField(int parameter){      return ((Integer) ((ArrayList) data.get(NUMBERARRAY)).get(parameter)).intValue();    }    public void setValue(int parameter, int number, String value) {       if(value !=null){          value=value.trim();          data.put(new Integer((VALUE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter), value);       }else{          data.put(new Integer((VALUE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter), "");       }    }    public void setUse(int parameter, int number, boolean use){          data.put(new Integer((USE*FIELDBOUNDRARY) + (NUMBERBOUNDRARY*number) + parameter), Boolean.valueOf(use));    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -