Package com.talend.camel.examples.springsecurity.common

Examples of com.talend.camel.examples.springsecurity.common.HelloWorld


    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);
        }
    }
View Full Code Here


            throw new RuntimeException("Admin should be able to invoke getUsers", ex);
        }
    }
   
    public void sayHelloAsUser() throws Exception {
        HelloWorld service = createServiceProxy("bob", "bobspassword");
        System.out.println("Using HelloServiceRest with user priviliges");
        System.out.println("Getting the list of existing users");
        try {
          Map<Integer, User> users = service.getUsers();
            printUsers(users);
            throw new RuntimeException("Only admin should be able to invoke getUsers");
        } catch (WebApplicationException ex) {
            Assert.assertEquals("403 response code is expected", 403, ex.getResponse().getStatus());
            System.out.println("Access was denied for user bob");
        }

        System.out.println("Asking the service to add a new user Barry 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");
        }
    }
View Full Code Here

            throw new RuntimeException("Should be able to sayHi");
        }
    }
   
    public HelloWorld createServiceProxy(String username, String password) {
        HelloWorld service = JAXRSClientFactory.create(address, HelloWorld.class, username, password, null);
        WebClient.getConfig(service).getHttpConduit().getClient().setReceiveTimeout(100000000);
        WebClient.getConfig(service).getOutInterceptors().add(new LoggingOutInterceptor());
        return service;
  }
View Full Code Here

TOP

Related Classes of com.talend.camel.examples.springsecurity.common.HelloWorld

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.