1 13 14 package org.ejbca.ui.web.admin.configuration; 15 16 import java.rmi.RemoteException ; 17 18 import javax.ejb.CreateException ; 19 import javax.naming.InitialContext ; 20 import javax.naming.NamingException ; 21 22 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionHome; 23 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionRemote; 24 import org.ejbca.core.model.log.Admin; 25 import org.ejbca.core.model.ra.raadmin.AdminPreference; 26 27 34 public class AdminPreferenceDataHandler implements java.io.Serializable { 35 36 37 public AdminPreferenceDataHandler(Admin administrator) throws RemoteException , NamingException , CreateException { 38 InitialContext jndicontext = new InitialContext (); 39 IRaAdminSessionHome raadminsessionhome = (IRaAdminSessionHome) javax.rmi.PortableRemoteObject.narrow(jndicontext.lookup("RaAdminSession"), 40 IRaAdminSessionHome.class); 41 raadminsession = raadminsessionhome.create(); 42 this.administrator = administrator; 43 } 44 45 46 public AdminPreference getAdminPreference(String certificatefingerprint) { 47 AdminPreference returnvalue=null; 48 49 try{ 50 returnvalue = raadminsession.getAdminPreference(administrator, certificatefingerprint); 51 }catch(Exception e) { 52 returnvalue=null; 53 } 54 return returnvalue; 55 } 56 57 58 public void addAdminPreference(String certificatefingerprint, AdminPreference adminpreference) 59 throws AdminExistsException, RemoteException { 60 if(!raadminsession.addAdminPreference(administrator, certificatefingerprint, adminpreference)) 61 throw new AdminExistsException("Admin already exists in the database."); 62 } 63 64 65 public void changeAdminPreference(String certificatefingerprint, AdminPreference adminpreference) 66 throws AdminDoesntExistException, RemoteException { 67 if(!raadminsession.changeAdminPreference(administrator, certificatefingerprint, adminpreference)) 68 throw new AdminDoesntExistException("Admin doesn't exists in the database."); 69 70 } 71 72 73 public void changeAdminPreferenceNoLog(String certificatefingerprint, AdminPreference adminpreference) 74 throws AdminDoesntExistException, RemoteException { 75 if(!raadminsession.changeAdminPreferenceNoLog(administrator, certificatefingerprint, adminpreference)) 76 throw new AdminDoesntExistException("Admin doesn't exists in the database."); 77 78 } 79 80 81 public boolean existsAdminPreference(String certificatefingerprint) throws RemoteException { 82 return raadminsession.existsAdminPreference(administrator, certificatefingerprint); 83 84 } 85 86 87 public AdminPreference getDefaultAdminPreference() throws RemoteException { 88 return raadminsession.getDefaultAdminPreference(administrator); 89 } 90 91 92 public void saveDefaultAdminPreference(AdminPreference adminpreference) throws RemoteException { 93 raadminsession.saveDefaultAdminPreference(administrator, adminpreference); 94 } 95 96 97 private IRaAdminSessionRemote raadminsession; 98 private Admin administrator; 99 } 100 | Popular Tags |