1 29 30 package hero.client.samples; 31 32 import javax.security.auth.login.LoginContext ; 33 import hero.client.test.SimpleCallbackHandler; 34 35 import hero.interfaces.ProjectSession; 36 import hero.interfaces.ProjectSessionHome; 37 import hero.interfaces.ProjectSessionUtil; 38 39 import hero.interfaces.UserSession; 40 import hero.interfaces.UserSessionHome; 41 import hero.interfaces.UserSessionUtil; 42 43 import hero.interfaces.UserRegistration; 44 import hero.interfaces.UserRegistrationHome; 45 import hero.interfaces.UserRegistrationUtil; 46 47 import java.util.*; 48 49 public class Sample1AdminWF{ 50 51 static public void main(String [] args) throws Exception { 52 char[] password={'t','o','t','o'}; 54 SimpleCallbackHandler handler = new SimpleCallbackHandler("admin",password); 55 LoginContext lc = new LoginContext ("TestClient", handler); 56 lc.login(); 57 58 UserRegistrationHome urHome = UserRegistrationUtil.getHome(); 60 UserRegistration userReg=urHome.create(); 61 62 try{ 64 userReg.userCreate("jack","jack","miguel.valdes-faura@ext.bull.net"); 65 }catch(Exception e){System.out.println(e) ;} 67 68 try{ 70 userReg.userCreate("john","john","miguel.valdes-faura@ext.bull.net"); 71 }catch(Exception e){System.out.println(e) ;} 73 userReg.remove(); 74 75 ProjectSessionHome prjSessionHome=ProjectSessionUtil.getHome(); 78 ProjectSession prjSession = prjSessionHome.create(); 79 80 try { 81 String instName = prjSession.instantiateProject("Order Processing"); 82 }catch(Exception e){System.out.println(e) ;} 84 UserSessionHome usHome=UserSessionUtil.getHome(); 88 UserSession uSession = usHome.create(); 89 90 try { 91 Collection names = uSession.getProjectInstancesNames("Order Processing"); 92 Iterator i = names.iterator() ; 93 prjSession.initProject((String ) i.next()); 94 95 prjSession.addUser("jack"); 97 prjSession.addUser("john"); 98 99 prjSession.setUserRole("jack","customer"); 101 prjSession.setUserRole("john","agent"); 103 104 }catch(Exception e){e.printStackTrace();} 106 107 prjSession.remove() ; 108 } 109 110 111 } 112 113 114 | Popular Tags |