1 package com.instantbank.servicing.control.util;
2
3 import java.rmi.RemoteException;
4 import javax.rmi.PortableRemoteObject;
5 import javax.naming.InitialContext;
6 import javax.naming.NamingException;
7 import javax.ejb.CreateException;
8 import javax.ejb.SessionContext;
9
10 import com.instantbank.common.utilcomponents.JNDINames;
11 import com.instantbank.component.parameter.ejb.ParameterHome;
12 import com.instantbank.servicing.control.ejb.ServicingControllerHome;
13
14
20 public final class EJBUtil {
21
22
28 public static ServicingControllerHome getServicingControllerHome() throws Exception {
29 try {
30 InitialContext initial = new InitialContext();
31 Object objref = initial.lookup(JNDINames.SERVICING_SCC_EJBHOME);
32 return (ServicingControllerHome)
33 PortableRemoteObject.narrow(objref, ServicingControllerHome.class);
34 }
35 catch(NamingException ne) {
36 throw new Exception(ne.getMessage());
37 }
38 }
39
40
41
47 public static ParameterHome getParameterHome() throws Exception {
48 try {
49 InitialContext initial = new InitialContext();
50 Object objref = initial.lookup(JNDINames.PARAMETER_EJBHOME);
51 return (ParameterHome)
52 PortableRemoteObject.narrow(objref, ParameterHome.class);
53 }
54 catch(NamingException ne) {
55 throw new Exception(ne.getMessage());
56 }
57 }
58
59
60
61
68 public static String getUserId(SessionContext context)
69 throws Exception {
70 String userId = context.getCallerPrincipal().getName();
71 return userId;
72 }
73
74
75
83 public static boolean isUserInRole(SessionContext context, String rol)
84 throws Exception {
85 return (context.isCallerInRole(rol));
86 }
87
88 }
89