Package org.glassfish.jersey

Examples of org.glassfish.jersey.SslConfigurator


        final LinkedBlockingQueue<Message> messages = new LinkedBlockingQueue<Message>();

        final Future<?> readerHandle = Executors.newSingleThreadExecutor().submit(new Runnable() {
            @Override
            public void run() {
                SslConfigurator sslConfig = SslConfigurator.newInstance()
                        .trustStoreFile("./truststore_client")
                        .trustStorePassword("asdfgh")

                        .keyStoreFile("./keystore_client")
                        .keyPassword("asdfgh");

                final Client client = ClientBuilder.newBuilder().sslContext(sslConfig.createSSLContext()).build();
                client.property(ClientProperties.CONNECT_TIMEOUT, 2000)
                        .register(new MoxyJsonFeature())
                        .register(HttpAuthenticationFeature.basic(App.getTwitterUserName(), App.getTwitterUserPassword()))
                        .register(GZipEncoder.class);
View Full Code Here


    /**
     * Test to see that the correct Http status is returned.
     */
    private void _testSSLWithBasicAndSSLAuth(ClientConfig clientConfig) {
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreFile(TRUSTORE_CLIENT_FILE)
                .trustStorePassword(TRUSTSTORE_CLIENT_PWD)
                .keyStoreFile(KEYSTORE_CLIENT_FILE)
                .keyPassword(KEYSTORE_CLIENT_PWD);

        final SSLContext sslContext = sslConfig.createSSLContext();
        Client client = ClientBuilder.newBuilder().withConfig(clientConfig)
                .sslContext(sslContext).build();

        // client basic auth demonstration
        client.register(HttpAuthenticationFeature.basic("user", "password"));
View Full Code Here

    /**
     * Test to see that HTTP 401 is returned when client tries to GET without
     * proper credentials.
     */
    private void _testWithoutBasicAuth(ClientConfig clientConfig) {
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreFile(TRUSTORE_CLIENT_FILE)
                .trustStorePassword(TRUSTSTORE_CLIENT_PWD)
                .keyStoreFile(KEYSTORE_CLIENT_FILE)
                .keyPassword(KEYSTORE_CLIENT_PWD);

        Client client = ClientBuilder.newBuilder().withConfig(clientConfig).sslContext(sslConfig
                .createSSLContext()).build();

        System.out.println("Client: GET " + Server.BASE_URI);

        WebTarget target = client.target(Server.BASE_URI);
View Full Code Here

    /**
     * Test to see that SSLHandshakeException is thrown when client don't have
     * trusted key.
     */
    private void _testWithoutSSLAuthentication(ClientConfig clientConfig) {
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreFile(TRUSTORE_CLIENT_FILE)
                .trustStorePassword(TRUSTSTORE_CLIENT_PWD);

        Client client = ClientBuilder.newBuilder()
                .withConfig(clientConfig)
                .sslContext(sslConfig.createSSLContext()).build();

        System.out.println("Client: GET " + Server.BASE_URI);

        WebTarget target = client.target(Server.BASE_URI);
        target.register(new LoggingFilter());
View Full Code Here

    @Override
    public JerseyClient build() {
        if (sslContext != null) {
            return new JerseyClient(config, sslContext, hostnameVerifier);
        } else if (sslConfigurator != null) {
            final SslConfigurator sslConfiguratorCopy = sslConfigurator.copy();
            return new JerseyClient(
                    config,
                    Values.lazy(new UnsafeValue<SSLContext, IllegalStateException>() {
                        @Override
                        public SSLContext get() throws IllegalStateException {
                            return sslConfiguratorCopy.createSSLContext();
                        }
                    }),
                    hostnameVerifier);
        } else {
            return new JerseyClient(config, (UnsafeValue<SSLContext, IllegalStateException>) null, hostnameVerifier);
View Full Code Here

        final LinkedBlockingQueue<Message> messages = new LinkedBlockingQueue<Message>();

        final Future<?> readerHandle = Executors.newSingleThreadExecutor().submit(new Runnable() {
            @Override
            public void run() {
                SslConfigurator sslConfig = SslConfigurator.newInstance()
                        .trustStoreFile("./truststore_client")
                        .trustStorePassword("asdfgh")

                        .keyStoreFile("./keystore_client")
                        .keyPassword("asdfgh");

                final Client client = ClientBuilder.newBuilder().sslContext(sslConfig.createSSLContext()).build();
                client.property(ClientProperties.CONNECT_TIMEOUT, 2000)
                        .register(new MoxyJsonFeature())
                        .register(new HttpBasicAuthFilter(App.getTwitterUserName(), App.getTwitterUserPassword()))
                        .register(GZipEncoder.class);
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.SslConfigurator

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.