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 Inscription { 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 ProjectSessionHome lHome=ProjectSessionUtil.getHome(); 60 ProjectSession lProject = lHome.create(); 61 String instName = lProject.instantiateProject("e-citizen"); 62 63 UserRegistrationHome urHome = UserRegistrationUtil.getHome(); 65 UserRegistration userReg=urHome.create(); 66 try{ 67 userReg.userCreate("user1","user1","miguel.valdes-faura@ext.bull.net"); 68 }catch(Exception e){} userReg.remove(); 70 71 urHome = UserRegistrationUtil.getHome(); 73 userReg=urHome.create(); 74 try{ 75 userReg.userCreate("agent1","agent1","miguel.valdes-faura@ext.bull.net"); 76 }catch(Exception e){} userReg.remove(); 78 79 lProject.addUser("user1"); 81 lProject.addUser("agent1"); 82 lProject.setUserRole("user1","InitialRole"); 84 lProject.setUserRole("agent1","agent"); 86 lProject.setProperty("userId","user1"); 88 lProject.setProperty("recordId","1111"); 89 lProject.setProperty("orderId","0001"); 90 91 char[] password2={'u','s','e','r','1'}; 93 handler = new SimpleCallbackHandler("user1",password2); 94 lc = new LoginContext ("TestClient", handler); 95 lc.login(); 96 97 UserSessionHome uHome=UserSessionUtil.getHome(); 99 UserSession uSession = uHome.create(); 100 Collection nodes = uSession.getToDoList(instName); 101 Iterator i = nodes.iterator(); 102 while (i.hasNext()) 103 { 104 String activityName = (String )i.next(); 105 uSession.startActivity(instName,activityName); 106 System.out.println("Start application activity... wait for termination"); 107 uSession.terminateActivity(instName,activityName); 108 System.out.println("Terminate activity"); 109 } 110 111 char[] password3={'a','g','e','n','t','1'}; 113 handler = new SimpleCallbackHandler("agent1",password3); 114 lc = new LoginContext ("TestClient", handler); 115 lc.login(); 116 117 uHome=UserSessionUtil.getHome(); 119 UserSession aSession = uHome.create(); 120 nodes = aSession.getToDoList(instName); 121 i = nodes.iterator(); 122 while (i.hasNext()) 123 { 124 String activityName = (String )i.next(); 125 ProjectSessionHome lHomeAgent1=ProjectSessionUtil.getHome(); 127 ProjectSession lProjectAgent1 = lHome.create(); 128 lProjectAgent1.initProject(instName); 129 130 lProjectAgent1.setNodeProperty(activityName,"correct","nok"); 131 aSession.startActivity(instName,activityName); 132 System.out.println("Start application activity... wait for termination"); 133 aSession.terminateActivity(instName,activityName); 134 System.out.println("Terminate activity"); 135 } 136 } 137 } 138 139 140 | Popular Tags |