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

📄 localraadminsessionbean.java

📁 一个免费的CA,基于EJB平台的,老师叫我们测试,现把之共享出来让大家参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
          throw new EJBException(e);        }        debug("<existsAdminPreference()");        return ret;    }// existsAdminPreference    /**     * Function that returns the default admin preference.     *     * @throws EJBException if a communication or other error occurs.     * @ejb.interface-method     * @ejb.transaction type="Supports"     */    public AdminPreference getDefaultAdminPreference(Admin admin){        debug(">getDefaultAdminPreference()");        AdminPreference ret =null;        try {            AdminPreferencesDataLocal apdata = adminpreferenceshome.findByPrimaryKey(DEFAULTUSERPREFERENCE);            ret = apdata.getAdminPreference();        } catch (javax.ejb.FinderException fe) {            try{               // Create new configuration              AdminPreferencesDataLocal apdata = adminpreferenceshome.create(DEFAULTUSERPREFERENCE,new AdminPreference());              ret = apdata.getAdminPreference();            }catch(Exception e){              throw new EJBException(e);            }        } catch(Exception e){          throw new EJBException(e);        }        debug("<getDefaultAdminPreference()");        return ret;    } // getDefaultPreference()     /**     * Function that saves the default admin preference.     *     * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method     */    public void saveDefaultAdminPreference(Admin admin, AdminPreference defaultadminpreference){       debug(">saveDefaultAdminPreference()");       try {          AdminPreferencesDataLocal apdata = adminpreferenceshome.findByPrimaryKey(DEFAULTUSERPREFERENCE);          apdata.setAdminPreference(defaultadminpreference);          String msg = intres.getLocalizedMessage("ra.defaultadminprefsaved");            	          getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_INFO_ADMINISTRATORPREFERENCECHANGED,msg);       } catch (Exception e) {           String msg = intres.getLocalizedMessage("ra.errorsavedefaultadminpref");            	           getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ADMINISTRATORPREFERENCECHANGED,msg);           throw new EJBException(e);       }        debug("<saveDefaultAdminPreference()");    } // saveDefaultAdminPreference	/**	  * Adds a profile to the database.	  *	  * @param admin administrator performing task	  * @param profilename readable profile name	  * @param profile profile to be added     * @ejb.interface-method	  *	  */	 public void addEndEntityProfile(Admin admin, String profilename, EndEntityProfile profile) throws EndEntityProfileExistsException {		 addEndEntityProfile(admin,findFreeEndEntityProfileId(),profilename,profile);	 } // addEndEntityProfile	 /**	  * Adds a profile to the database.	  *	  * @param admin administrator performing task	  * @param profileid internal ID of new profile, use only if you know it's right.	  * @param profilename readable profile name	  * @param profile profile to be added      * @ejb.interface-method	  *	  */	 public void addEndEntityProfile(Admin admin, int profileid, String profilename, EndEntityProfile profile) throws EndEntityProfileExistsException{		if(profilename.trim().equalsIgnoreCase(EMPTY_ENDENTITYPROFILENAME)){			String msg = intres.getLocalizedMessage("ra.erroraddprofile", profilename);            				getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);			throw new EndEntityProfileExistsException();		}		if (isFreeEndEntityProfileId(profileid) == false) {			String msg = intres.getLocalizedMessage("ra.erroraddprofile", profilename);            				getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);			throw new EndEntityProfileExistsException();		}		try {			profiledatahome.findByProfileName(profilename);			String msg = intres.getLocalizedMessage("ra.erroraddprofile", profilename);            				getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);			throw new EndEntityProfileExistsException();		} catch (FinderException e) {			try {				profiledatahome.create(new Integer(profileid), profilename, profile);				String msg = intres.getLocalizedMessage("ra.addedprofile", profilename);            					getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(), null, null,						LogEntry.EVENT_INFO_ENDENTITYPROFILE,msg);			} catch (Exception f) {				String msg = intres.getLocalizedMessage("ra.erroraddprofile", profilename);            					error(msg, e);				logsession.log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(), null, null,						LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);			}		 }	 } // addEndEntityProfile     /**     * Adds a end entity profile to a group with the same content as the original profile.      * @ejb.interface-method     */    public void cloneEndEntityProfile(Admin admin, String originalprofilename, String newprofilename) throws EndEntityProfileExistsException{       EndEntityProfile profile = null;       if(newprofilename.trim().equalsIgnoreCase(EMPTY_ENDENTITYPROFILENAME)){    	   String msg = intres.getLocalizedMessage("ra.errorcloneprofile", newprofilename, originalprofilename);            	    	   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);    	   throw new EndEntityProfileExistsException();       }       try{         EndEntityProfileDataLocal pdl = profiledatahome.findByProfileName(originalprofilename);         profile = (EndEntityProfile) pdl.getProfile().clone();         try{           profiledatahome.findByProfileName(newprofilename);    	   String msg = intres.getLocalizedMessage("ra.errorcloneprofile", newprofilename, originalprofilename);            	           getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);           throw new EndEntityProfileExistsException();         }catch(FinderException e){            profiledatahome.create(new Integer(findFreeEndEntityProfileId()),newprofilename,profile);			String msg = intres.getLocalizedMessage("ra.clonedprofile", newprofilename, originalprofilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_INFO_ENDENTITYPROFILE,msg);         }       }catch(Exception e){    	   String msg = intres.getLocalizedMessage("ra.errorcloneprofile", newprofilename, originalprofilename);            	    	   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA,  new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);       }    } // cloneEndEntityProfile     /**     * Removes an end entity profile from the database.     * @throws EJBException if a communication or other error occurs.      * @ejb.interface-method     */    public void removeEndEntityProfile(Admin admin, String profilename) {        try{            EndEntityProfileDataLocal pdl = profiledatahome.findByProfileName(profilename);            pdl.remove();			String msg = intres.getLocalizedMessage("ra.removedprofile", profilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_INFO_ENDENTITYPROFILE,msg);        }catch(Exception e){			String msg = intres.getLocalizedMessage("ra.errorremoveprofile", profilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);        }    } // removeEndEntityProfile     /**     * Renames a end entity profile      * @ejb.interface-method     */    public void renameEndEntityProfile(Admin admin, String oldprofilename, String newprofilename) throws EndEntityProfileExistsException{        if(newprofilename.trim().equalsIgnoreCase(EMPTY_ENDENTITYPROFILENAME) || oldprofilename.trim().equalsIgnoreCase(EMPTY_ENDENTITYPROFILENAME)){        	String msg = intres.getLocalizedMessage("ra.errorrenameprofile", oldprofilename, newprofilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);            throw new EndEntityProfileExistsException();        }       try{           profiledatahome.findByProfileName(newprofilename);    	   String msg = intres.getLocalizedMessage("ra.errorrenameprofile", oldprofilename, newprofilename);            	           getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);           throw new EndEntityProfileExistsException();       }catch(FinderException e){           try{               EndEntityProfileDataLocal pdl = profiledatahome.findByProfileName(oldprofilename);               pdl.setProfileName(newprofilename);               String msg = intres.getLocalizedMessage("ra.renamedprofile", oldprofilename, newprofilename);            	               getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_INFO_ENDENTITYPROFILE,msg );           }catch(FinderException f){        	   String msg = intres.getLocalizedMessage("ra.errorrenameprofile", oldprofilename, newprofilename);            	        	   getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg );           }       }    } // renameProfile    /**     * Updates profile data     * @ejb.interface-method     */    public void changeEndEntityProfile(Admin admin, String profilename, EndEntityProfile profile){        try{            EndEntityProfileDataLocal pdl = profiledatahome.findByProfileName(profilename);            pdl.setProfile(profile);			String msg = intres.getLocalizedMessage("ra.changedprofile", profilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_INFO_ENDENTITYPROFILE,msg);        }catch(FinderException e){			String msg = intres.getLocalizedMessage("ra.errorchangeprofile", profilename);            	            getLogSession().log(admin, admin.getCaId(), LogEntry.MODULE_RA, new java.util.Date(),null, null, LogEntry.EVENT_ERROR_ENDENTITYPROFILE,msg);        }    }// changeEndEntityProfile    /**     * Retrives a Collection of id:s (Integer) to authorized profiles.     * @ejb.transaction type="Supports"     * @ejb.interface-method     */    public Collection getAuthorizedEndEntityProfileIds(Admin admin){      ArrayList returnval = new ArrayList();      Collection result = null;      HashSet authorizedcaids = new HashSet(getAuthorizationSession().getAuthorizedCAIds(admin));      //debug("Admin authorized to "+authorizedcaids.size()+" CAs.");      try{          if(getAuthorizationSession().isAuthorizedNoLog(admin, "/super_administrator"))              returnval.add(new Integer(SecConst.EMPTY_ENDENTITYPROFILE));        }catch(AuthorizationDeniedException e){}      try{          result = profiledatahome.findAll();          Iterator i = result.iterator();          while(i.hasNext()){              EndEntityProfileDataLocal next = (EndEntityProfileDataLocal) i.next();              // Check if all profiles available CAs exists in authorizedcaids.              String value = next.getProfile().getValue(EndEntityProfile.AVAILCAS, 0);              //debug("AvailCAs: "+value);              if (value != null) {                  String[] availablecas = value.split(EndEntityProfile.SPLITCHAR);                  //debug("No of available CAs: "+availablecas.length);                  boolean allexists = true;                  for(int j=0; j < availablecas.length; j++){                      //debug("Available CA["+j+"]: "+availablecas[j]);                      if(!authorizedcaids.contains( new Integer(availablecas[j]))){                          allexists = false;                          //debug("Profile "+next.getId()+" not authorized");                          break;                      }                  }                  if(allexists) {                      //debug("Adding "+next.getId());                      returnval.add(next.getId());                  }              }          }      }catch(Exception e){    	  String msg = intres.getLocalizedMessage("ra.errorgetids");    	            error(msg, e);      }      return returnval;    } // getAuthorizedEndEntityProfileNames    /**     * Method creating a hashmap mapping profile id (Integer) to profile name (String).     * @ejb.transaction type="Supports"     * @ejb.interface-method     */    public HashMap getEndEntityProfileIdToNameMap(Admin admin){        debug(">getEndEntityProfileIdToNameMap");        HashMap returnval = new HashMap();        Collection result = null;        returnval.put(new Integer(SecConst.EMPTY_ENDENTITYPROFILE),EMPTY_ENDENTITYPROFILENAME);        try{            result = profiledatahome.findAll();            //debug("Found "+result.size()+ " end entity profiles.");            Iterator i = result.iterator();            while(i.hasNext()){                EndEntityProfileDataLocal next = (EndEntityProfileDataLocal) i.next();                //debug("Added "+next.getId()+ ", "+next.getProfileName());                returnval.put(next.getId(),next.getProfileName());            }        }catch(Exception e) {        	String msg = intres.getLocalizedMessage("ra.errorreadprofiles");    	              error(msg, e);        }        debug(">getEndEntityProfileIdToNameMap");        return returnval;      } // getEndEntityProfileIdToNameMap     /**     * Finds a end entity profile by id.     * @ejb.transaction type="Supports"      * @ejb.interface-method     */    public EndEntityProfile getEndEntityProfile(Admin admin, int id){    	if (log.isDebugEnabled()) {            debug(">getEndEntityProfile("+id+")");    		    	}

⌨️ 快捷键说明

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