public RESTClient(int port) {
address = "http://localhost:" + port + "/spring-security/HelloWorld";
}
public void sayHelloAsAdmin() throws Exception {
HelloWorld service = createServiceProxy("jim", "jimspassword");
System.out.println("Using HelloServiceRest with admin priviliges");
System.out.println("Asking the service to add a new user and also say hi");
try {
System.out.println(service.sayHi("Barry"));
System.out.println(service.sayHiToUser(new UserImpl("Barry")));
} catch (WebApplicationException ex) {
throw new RuntimeException("Should be able to sayHi", ex);
}
System.out.println("Getting the list of existing users");
try {
Map<Integer, User> users = service.getUsers();
printUsers(users);
} catch (WebApplicationException ex) {
throw new RuntimeException("Admin should be able to invoke getUsers", ex);
}
}