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

📄 localhardtokensessionbean.java

📁 一个免费的CA,基于EJB平台的,老师叫我们测试,现把之共享出来让大家参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    }catch(FinderException e){	        try{	            hardtokenprofilehome.findByPrimaryKey(new Integer(profileid));	        }catch(FinderException f){	            try{	                hardtokenprofilehome.create(new Integer(profileid), name, profile);	                success = true;	            }catch(CreateException g){	                error("Unexpected error creating new hard token profile: ", g);      	            }	        }	    }	    	    if(success) {            String msg = intres.getLocalizedMessage("hardtoken.addedprofile", name);            		        getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENPROFILEDATA, msg);	    } else {            String msg = intres.getLocalizedMessage("hardtoken.erroraddprofile", name);            		        getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKENPROFILEDATA, msg);	    }	    	    if(!success)	        throw new HardTokenProfileExistsException();	    debug("<addHardTokenProfile()");	} // addHardTokenProfile	/**	 * Updates hard token profile data	 *	 * @throws EJBException if a communication or other error occurs.     * @ejb.interface-method view-type="both"     * @ejb.transaction type="Required"	 */	public void changeHardTokenProfile(Admin admin, String name, HardTokenProfile profile){	   debug(">changeHardTokenProfile(name: " + name + ")");	   boolean success = false;	   try{		 HardTokenProfileDataLocal htp = hardtokenprofilehome.findByName(name);		 htp.setHardTokenProfile(profile);		 success = true;	   }catch(FinderException e){}	   if(success) {           String msg = intres.getLocalizedMessage("hardtoken.editedprofile", name);            	           getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENPROFILEDATA, msg);	   } else {           String msg = intres.getLocalizedMessage("hardtoken.erroreditprofile", name);            	           getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKENPROFILEDATA, msg);	   }	   debug("<changeHardTokenProfile()");	} // changeHardTokenProfile	 /**	 * Adds a hard token profile with the same content as the original profile,	 *	 * @throws HardTokenProfileExistsException if hard token already exists.	 * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method view-type="both"      * @ejb.transaction type="Required"	 */	public void cloneHardTokenProfile(Admin admin, String oldname, String newname) throws HardTokenProfileExistsException{	   debug(">cloneHardTokenProfile(name: " + oldname + ")");	   HardTokenProfile profiledata = null;	   try{		 HardTokenProfileDataLocal htp = hardtokenprofilehome.findByName(oldname);		 profiledata = (HardTokenProfile) htp.getHardTokenProfile().clone();         try{        	 addHardTokenProfile(admin, newname, profiledata);        	 String msg = intres.getLocalizedMessage("hardtoken.clonedprofile", newname, oldname);            	        	 getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENPROFILEDATA, msg);         }catch(HardTokenProfileExistsException f){             String msg = intres.getLocalizedMessage("hardtoken.errorcloneprofile", newname, oldname);            	             getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKENPROFILEDATA, msg);             throw f;         }	   }catch(Exception e){		  throw new EJBException(e);	   }	   debug("<cloneHardTokenProfile()");	} // cloneHardTokenProfile	 /**	 * Removes a hard token profile from the database.	 *	 * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method view-type="both"      * @ejb.transaction type="Required"	 */	public void removeHardTokenProfile(Admin admin, String name){	  debug(">removeHardTokenProfile(name: " + name + ")");	  try{		HardTokenProfileDataLocal htp = hardtokenprofilehome.findByName(name);		htp.remove();        String msg = intres.getLocalizedMessage("hardtoken.removedprofile", name);            			getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENPROFILEDATA,msg);	  }catch(Exception e){          String msg = intres.getLocalizedMessage("hardtoken.errorremoveprofile", name);            	          getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKENPROFILEDATA,msg,e);	  }	  debug("<removeHardTokenProfile()");	} // removeHardTokenProfile	 /**	 * Renames a hard token profile	 *	 * @throws HardTokenProfileExistsException if hard token already exists.	 * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method view-type="both"      * @ejb.transaction type="Required"	 */	public void renameHardTokenProfile(Admin admin, String oldname, String newname) throws HardTokenProfileExistsException{	   debug(">renameHardTokenProfile(from " + oldname + " to " + newname + ")");	   boolean success = false;	   try{		  hardtokenprofilehome.findByName(newname);	   }catch(FinderException e){		  try{			 HardTokenProfileDataLocal htp = hardtokenprofilehome.findByName(oldname);			 htp.setName(newname);			 success = true;		  }catch(FinderException g){}	   }	   if(success) {		   String msg = intres.getLocalizedMessage("hardtoken.renamedprofile", oldname, newname);            			   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENPROFILEDATA,msg);	   } else {		   String msg = intres.getLocalizedMessage("hardtoken.errorrenameprofile", oldname, newname);            			   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_HARDTOKENPROFILEDATA, msg);	   }       if(!success)	     throw new HardTokenProfileExistsException();	   debug("<renameHardTokenProfile()");	} // renameHardTokenProfile	/**	 * Retrives a Collection of id:s (Integer) to authorized profiles.	 * 	 * Authorized hard token profiles are profiles containing only authorized certificate profiles and caids.	 *	 * @return Collection of id:s (Integer)     * @ejb.interface-method view-type="both"	 */	public Collection getAuthorizedHardTokenProfileIds(Admin admin){	  ArrayList returnval = new ArrayList();	  Collection result = null;	  HashSet authorizedcertprofiles = new HashSet(getCertificateStoreSession().getAuthorizedCertificateProfileIds(admin, CertificateDataBean.CERTTYPE_HARDTOKEN));      HashSet authorizedcaids = new HashSet(this.getAuthorizationSession().getAuthorizedCAIds(admin));	  	  try{		result = this.hardtokenprofilehome.findAll();		Iterator i = result.iterator();		while(i.hasNext()){		  HardTokenProfileDataLocal next = (HardTokenProfileDataLocal) i.next();		  HardTokenProfile profile = next.getHardTokenProfile();		  if(profile instanceof EIDProfile){		  	if(authorizedcertprofiles.containsAll(((EIDProfile) profile).getAllCertificateProfileIds()) &&		  	   authorizedcaids.containsAll(((EIDProfile) profile).getAllCAIds())){		  	  returnval.add(next.getId());		  	}		  }else{		  	//Implement for other profile types		  }		}	  }catch(FinderException e){}	  return returnval;	} // getAuthorizedHardTokenProfileIds	/**	 * Method creating a hashmap mapping profile id (Integer) to profile name (String).     * @ejb.interface-method view-type="both"	 */	public HashMap getHardTokenProfileIdToNameMap(Admin admin){	  HashMap returnval = new HashMap();	  Collection result = null;	  try{		result = hardtokenprofilehome.findAll();		Iterator i = result.iterator();		while(i.hasNext()){		  HardTokenProfileDataLocal next = (HardTokenProfileDataLocal) i.next();		  returnval.put(next.getId(),next.getName());		}	  }catch(FinderException e){}	  return returnval;	} // getHardTokenProfileIdToNameMap	/**	 * Retrives a named hard token profile.     * @ejb.interface-method view-type="both"	 */	public HardTokenProfile getHardTokenProfile(Admin admin, String name){	  HardTokenProfile returnval=null;	   try{		 returnval = (hardtokenprofilehome.findByName(name)).getHardTokenProfile();	   } catch(FinderException e){		   // return null if we cant find it	   }	   return returnval;	} //  getCertificateProfile	 /**      * Finds a hard token profile by id.      * @ejb.interface-method view-type="both"	  */	public HardTokenProfile getHardTokenProfile(Admin admin, int id){	   HardTokenProfile returnval=null;  	   try{		   returnval = (hardtokenprofilehome.findByPrimaryKey(new Integer(id))).getHardTokenProfile();	   } catch(FinderException e){			 // return null if we cant find it	   }	   return returnval;	} // getHardTokenProfile	/**	 * Help method used by hard token profile proxys to indicate if it is time to	 * update it's profile data.     * @ejb.interface-method view-type="both"	 */	public int getHardTokenProfileUpdateCount(Admin admin, int hardtokenprofileid){	  int returnval = 0;	  try{	  	returnval = (hardtokenprofilehome.findByPrimaryKey(new Integer(hardtokenprofileid))).getUpdateCounter();	  }catch(FinderException e){}	  return returnval;	}	 /**	 * Returns a hard token profile id, given it's hard token profile name	 *	 *	 * @return the id or 0 if hardtokenprofile cannot be found.      * @ejb.interface-method view-type="both"	 */	public int getHardTokenProfileId(Admin admin, String name){	  int returnval = 0;	  try{		Integer id = (hardtokenprofilehome.findByName(name)).getId();		returnval = id.intValue();	  }catch(FinderException e){}	  return returnval;	} // getHardTokenProfileId     /**      * Returns a hard token profile name given its id. 	  *	  * @return the name or null if id noesnt exists	  * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method view-type="both"	  */	public String getHardTokenProfileName(Admin admin, int id){	  debug(">getHardTokenProfileName(id: " + id + ")");	  String returnval = null;	  HardTokenProfileDataLocal htp = null;	  try{		htp = hardtokenprofilehome.findByPrimaryKey(new Integer(id));		if(htp != null){		  returnval = htp.getName();		}	  }catch(FinderException e){}	  debug("<getHardTokenProfileName()");	  return returnval;	} // getHardTokenProfileName    /**     * Adds a hard token issuer to the database.     *     * @return false if hard token issuer already exists.     * @throws EJBException if a communication or other error occurs.     * @ejb.interface-method view-type="both"     * @ejb.transaction type="Required"     */    public boolean addHardTokenIssuer(Admin admin, String alias, int admingroupid, HardTokenIssuer issuerdata){       debug(">addHardTokenIssuer(alias: " + alias + ")");       boolean returnval=false;       try{          hardtokenissuerhome.findByAlias(alias);       }catch(FinderException e){         try{           hardtokenissuerhome.create(findFreeHardTokenIssuerId(), alias, admingroupid, issuerdata);           returnval = true;         }catch(CreateException g){}       }       if(returnval) {    	   String msg = intres.getLocalizedMessage("hardtoken.addedissuer", alias);            	    	   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_HARDTOKEN, new java.util.Date(),null, null, LogEntry.EVENT_INFO_HARDTOKENISSUERDATA,msg);

⌨️ 快捷键说明

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