Example usage for org.apache.http.impl.cookie RFC2109VersionHandler RFC2109VersionHandler

List of usage examples for org.apache.http.impl.cookie RFC2109VersionHandler RFC2109VersionHandler

Introduction

In this page you can find the example usage for org.apache.http.impl.cookie RFC2109VersionHandler RFC2109VersionHandler.

Prototype

public RFC2109VersionHandler() 

Source Link

Usage

From source file:com.machinepublishers.jbrowserdriver.LaxCookieSpecProvider.java

@Override
public CookieSpec create(final HttpContext context) {
    if (cookieSpec == null) {
        synchronized (this) {
            if (cookieSpec == null) {
                try {
                    Constructor constructor = RFC2965Spec.class.getDeclaredConstructor(boolean.class,
                            CommonCookieAttributeHandler[].class);
                    constructor.setAccessible(true);
                    final RFC2965Spec strict = (RFC2965Spec) constructor.newInstance(false,
                            (Object) new CommonCookieAttributeHandler[] { new RFC2965VersionAttributeHandler(),
                                    new BasicPathHandler() {
                                        @Override
                                        public void validate(final Cookie cookie, final CookieOrigin origin)
                                                throws MalformedCookieException {
                                            // No validation
                                        }
                                    }, new PublicSuffixFilter(PublicSuffixDomainFilter
                                            .decorate(new RFC2965DomainAttributeHandler() {
                                                @Override
                                                public void validate(Cookie cookie, CookieOrigin origin)
                                                        throws MalformedCookieException {
                                                    // No validation
                                                }
                                            }, PublicSuffixMatcherLoader.getDefault())),
                                    new RFC2965PortAttributeHandler(), new BasicMaxAgeHandler(),
                                    new BasicSecureHandler(), new BasicCommentHandler(),
                                    new RFC2965CommentUrlAttributeHandler(),
                                    new RFC2965DiscardAttributeHandler() });
                    constructor = RFC2109Spec.class.getDeclaredConstructor(boolean.class,
                            CommonCookieAttributeHandler[].class);
                    constructor.setAccessible(true);
                    final RFC2109Spec obsoleteStrict = (RFC2109Spec) constructor.newInstance(false,
                            (Object) new CommonCookieAttributeHandler[] { new RFC2109VersionHandler(),
                                    new BasicPathHandler() {
                                        @Override
                                        public void validate(final Cookie cookie, final CookieOrigin origin)
                                                throws MalformedCookieException {
                                            // No validation
                                        }
                                    }, new PublicSuffixFilter(
                                            PublicSuffixDomainFilter.decorate(new RFC2109DomainHandler() {
                                                @Override
                                                public void validate(Cookie cookie, CookieOrigin origin)
                                                        throws MalformedCookieException {
                                                    // No validation
                                                }
                                            }, PublicSuffixMatcherLoader.getDefault())),
                                    new BasicMaxAgeHandler(), new BasicSecureHandler(),
                                    new BasicCommentHandler() });
                    constructor = NetscapeDraftSpec.class
                            .getDeclaredConstructor(CommonCookieAttributeHandler[].class);
                    constructor.setAccessible(true);
                    final NetscapeDraftSpec netscapeDraft = (NetscapeDraftSpec) constructor
                            .newInstance((Object) new CommonCookieAttributeHandler[] { new PublicSuffixFilter(
                                    PublicSuffixDomainFilter.decorate(new BasicDomainHandler() {
                                        @Override
                                        public void validate(Cookie cookie, CookieOrigin origin)
                                                throws MalformedCookieException {
                                            // No validation 
                                        }
                                    }, PublicSuffixMatcherLoader.getDefault())), new BasicPathHandler() {
                                        @Override
                                        public void validate(final Cookie cookie, final CookieOrigin origin)
                                                throws MalformedCookieException {
                                            // No validation
                                        }
                                    }, new BasicSecureHandler(), new BasicCommentHandler(),
                                    new BasicExpiresHandler(DATE_PATTERNS) });
                    constructor = DefaultCookieSpec.class.getDeclaredConstructor(RFC2965Spec.class,
                            RFC2109Spec.class, NetscapeDraftSpec.class);
                    constructor.setAccessible(true);
                    this.cookieSpec = (DefaultCookieSpec) constructor.newInstance(strict, obsoleteStrict,
                            netscapeDraft);
                } catch (Throwable t) {
                    Util.handleException(t);
                }//ww  w .jav  a2s .  co  m
            }
        }
    }
    return this.cookieSpec;
}