Package org.glassfish.jersey

Examples of org.glassfish.jersey.SslConfigurator


     
      SSLContext context = null;
            context = SSLContext.getInstance("SSL");
            context.init(null, null, null);
           
            SslConfigurator sslConfig = SslConfigurator.newInstance();
                /*
                    .trustStoreFile("./truststore_client")
                    .trustStorePassword("asdfgh")

                    .keyStoreFile("./keystore_client")
                    .keyPassword("asdfgh");
                    */
                //old: CLIENT.property(ClientProperties.SSL_CONFIG, new SslConfig(context));
           
            CLIENT = ClientBuilder.newBuilder().sslContext(sslConfig.createSSLContext()).build();
     
      DEFAULT_MAPPER = new ObjectMapper();
     
      DEFAULT_MAPPER.setSerializationInclusion(Inclusion.NON_NULL);
      DEFAULT_MAPPER.enable(SerializationConfig.Feature.INDENT_OUTPUT);
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() {
                            return sslConfiguratorCopy.createSSLContext();
                        }
                    }),
                    hostnameVerifier);
        } else {
            return new JerseyClient(config, (UnsafeValue<SSLContext, IllegalStateException>) null, hostnameVerifier);
View Full Code Here

     */
    @Test
    public void testSSLWithAuth() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        final InputStream keyStore = MainTest.class.getResourceAsStream("/keystore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh")
                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
                .keyPassword("asdfgh");

View Full Code Here

     */
    @Test
    public void testHTTPBasicAuth1() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        final InputStream keyStore = MainTest.class.getResourceAsStream("/keystore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh")
                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
                .keyPassword("asdfgh");

View Full Code Here

     * trusted key.
     */
    @Test
    public void testSSLAuth1() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh");

        ClientConfig cc = new ClientConfig();
        cc.property(ApacheClientProperties.SSL_CONFIG, sslConfig);
View Full Code Here

    private SSLContext getSslContext(final Configuration config) {
        if (config == null) {
            return null;
        }

        final SslConfigurator sslConfigurator = ApacheClientProperties.getValue(
                config.getProperties(),
                ApacheClientProperties.SSL_CONFIG,
                SslConfigurator.class);

        return sslConfigurator != null ? sslConfigurator.createSSLContext() : null;
    }
View Full Code Here

     * Create the new Jetty client connector.
     *
     * @param config client configuration.
     */
    JettyConnector(final Configuration config) {
        SslConfigurator sslConfig = null;
        if (config != null) {
            sslConfig = JettyClientProperties.getValue(config.getProperties(), JettyClientProperties.SSL_CONFIG,
                    SslConfigurator.class);
        }
        if (sslConfig != null) {
            final SslContextFactory sslContextFactory = new SslContextFactory();
            sslContextFactory.setSslContext(sslConfig.createSSLContext());
            this.client = new HttpClient(sslContextFactory);
        } else {
            this.client = new HttpClient();
        }

View Full Code Here

     */
    @Test
    public void testSSLWithAuth() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        final InputStream keyStore = MainTest.class.getResourceAsStream("/keystore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh")
                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
                .keyPassword("asdfgh");

View Full Code Here

     */
    @Test
    public void testHTTPBasicAuth1() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        final InputStream keyStore = MainTest.class.getResourceAsStream("/keystore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh")
                .keyStoreBytes(ByteStreams.toByteArray(keyStore))
                .keyPassword("asdfgh");

View Full Code Here

     * trusted key. Jetty throws javax.ws.rs.NotAuthorizedException: HTTP 401 Unauthorized.
     */
    @Test
    public void testSSLAuth1() throws Exception {
        final InputStream trustStore = MainTest.class.getResourceAsStream("/truststore_client");
        SslConfigurator sslConfig = SslConfigurator.newInstance()
                .trustStoreBytes(ByteStreams.toByteArray(trustStore))
                .trustStorePassword("asdfgh");

        ClientConfig cc = new ClientConfig();
        cc.property(JettyClientProperties.SSL_CONFIG, sslConfig);
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.