private boolean acceptPath( String pathPattern, String hostPath ) { return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); }
private boolean reportCookieRejected( int reason, String attribute, String source ) { CookieProperties.reportCookieRejected( reason, attribute, source ); return false; }
/** * get the domainAttribute Status for the given domainAttribute with the given sourceHost * @see http://wp.netscape.com/newsref/std/cookie_spec.html * @param domainAttribute * @param sourceHost * @return */ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) { // patch according to [ 1476380 ] Cookies incorrectly rejected despite valid domain if (domainAttribute.equals(sourceHost)) { return CookieListener.ACCEPTED; } if (!domainAttribute.startsWith(".")) domainAttribute = '.' + domainAttribute; if (domainAttribute.lastIndexOf('.') == 0) { return CookieListener.DOMAIN_ONE_DOT; } else if (!sourceHost.endsWith( domainAttribute )) { return CookieListener.DOMAIN_NOT_SOURCE_SUFFIX; } else if (CookieProperties.isDomainMatchingStrict() && sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) { return CookieListener.DOMAIN_TOO_MANY_LEVELS; } else { return CookieListener.ACCEPTED; } }
private JavaNet(WebConversation wc) { super(null); this.wc = wc; // disable scripting support HttpUnitOptions.setScriptingEnabled(false); // java.net security certificate cause a problem. So avoid it by disabling certificate validation. SSLTrustAllManager.install(); // we need this to work around the broken cookies in java.net CookieProperties.setDomainMatchingStrict(false); // IssueZilla always have a DTD but for a restricted access project, it fails to resolve. // so just stop looking at DTD altogether. try { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",false); wc.setDocumentBuilderFactory(dbf); } catch (ParserConfigurationException e) { throw new Error(e); } }
/** * get the domainAttribute Status for the given domainAttribute with the given sourceHost * @see http://wp.netscape.com/newsref/std/cookie_spec.html * @param domainAttribute * @param sourceHost * @return */ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) { // patch according to [ 1476380 ] Cookies incorrectly rejected despite valid domain if (domainAttribute.equals(sourceHost)) { return CookieListener.ACCEPTED; } if (!domainAttribute.startsWith(".")) domainAttribute = '.' + domainAttribute; if (domainAttribute.lastIndexOf('.') == 0) { return CookieListener.DOMAIN_ONE_DOT; } else if (!sourceHost.endsWith( domainAttribute )) { return CookieListener.DOMAIN_NOT_SOURCE_SUFFIX; } else if (CookieProperties.isDomainMatchingStrict() && sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) { return CookieListener.DOMAIN_TOO_MANY_LEVELS; } else { return CookieListener.ACCEPTED; } }
private boolean acceptPath( String pathPattern, String hostPath ) { return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); }
/** * get the domainAttribute Status for the given domainAttribute with the given sourceHost * @see http://wp.netscape.com/newsref/std/cookie_spec.html * @param domainAttribute * @param sourceHost * @return */ private int getDomainAttributeStatus( String domainAttribute, String sourceHost ) { // patch according to [ 1476380 ] Cookies incorrectly rejected despite valid domain if (domainAttribute.equals(sourceHost)) { return CookieListener.ACCEPTED; } if (!domainAttribute.startsWith(".")) domainAttribute = '.' + domainAttribute; if (domainAttribute.lastIndexOf('.') == 0) { return CookieListener.DOMAIN_ONE_DOT; } else if (!sourceHost.endsWith( domainAttribute )) { return CookieListener.DOMAIN_NOT_SOURCE_SUFFIX; } else if (CookieProperties.isDomainMatchingStrict() && sourceHost.lastIndexOf( domainAttribute ) > sourceHost.indexOf( '.' )) { return CookieListener.DOMAIN_TOO_MANY_LEVELS; } else { return CookieListener.ACCEPTED; } }
private boolean reportCookieRejected( int reason, String attribute, String source ) { CookieProperties.reportCookieRejected( reason, attribute, source ); return false; }
private boolean acceptPath( String pathPattern, String hostPath ) { return !CookieProperties.isPathMatchingStrict() || hostPath.startsWith( pathPattern ); }
/** * accept the given cookie * @param cookie * @return */ private boolean acceptCookie( Cookie cookie ) { if (cookie.getPath() == null) { cookie.setPath( getParentPath( _sourceURL.getPath() ) ); } else { int status = getPathAttributeStatus( cookie.getPath(), _sourceURL.getPath() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getPath(), cookie.getName() ); return false; } } if (cookie.getDomain() == null) { cookie.setDomain( _sourceURL.getHost() ); } else if (!CookieProperties.isDomainMatchingStrict() && cookie.getDomain().equalsIgnoreCase( _sourceURL.getHost() )) { cookie.setDomain( _sourceURL.getHost() ); } else { int status = getDomainAttributeStatus( cookie.getDomain(), _sourceURL.getHost() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getDomain(), cookie.getName() ); return false; } } return true; }
private boolean reportCookieRejected( int reason, String attribute, String source ) { CookieProperties.reportCookieRejected( reason, attribute, source ); return false; }
private int getPathAttributeStatus( String pathAttribute, String sourcePath ) { if (!CookieProperties.isPathMatchingStrict() || sourcePath.length() == 0 || sourcePath.startsWith( pathAttribute )) { return CookieListener.ACCEPTED; } else { return CookieListener.PATH_NOT_PREFIX; } }
/** * accept the given cookie * @param cookie * @return */ private boolean acceptCookie( Cookie cookie ) { if (cookie.getPath() == null) { cookie.setPath( getParentPath( _sourceURL.getPath() ) ); } else { int status = getPathAttributeStatus( cookie.getPath(), _sourceURL.getPath() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getPath(), cookie.getName() ); return false; } } if (cookie.getDomain() == null) { cookie.setDomain( _sourceURL.getHost() ); } else if (!CookieProperties.isDomainMatchingStrict() && cookie.getDomain().equalsIgnoreCase( _sourceURL.getHost() )) { cookie.setDomain( _sourceURL.getHost() ); } else { int status = getDomainAttributeStatus( cookie.getDomain(), _sourceURL.getHost() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getDomain(), cookie.getName() ); return false; } } return true; }
private int getPathAttributeStatus( String pathAttribute, String sourcePath ) { if (!CookieProperties.isPathMatchingStrict() || sourcePath.length() == 0 || sourcePath.startsWith( pathAttribute )) { return CookieListener.ACCEPTED; } else { return CookieListener.PATH_NOT_PREFIX; } }
/** * accept the given cookie * @param cookie * @return */ private boolean acceptCookie( Cookie cookie ) { if (cookie.getPath() == null) { cookie.setPath( getParentPath( _sourceURL.getPath() ) ); } else { int status = getPathAttributeStatus( cookie.getPath(), _sourceURL.getPath() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getPath(), cookie.getName() ); return false; } } if (cookie.getDomain() == null) { cookie.setDomain( _sourceURL.getHost() ); } else if (!CookieProperties.isDomainMatchingStrict() && cookie.getDomain().equalsIgnoreCase( _sourceURL.getHost() )) { cookie.setDomain( _sourceURL.getHost() ); } else { int status = getDomainAttributeStatus( cookie.getDomain(), _sourceURL.getHost() ); if (status != CookieListener.ACCEPTED) { reportCookieRejected( status, cookie.getDomain(), cookie.getName() ); return false; } } return true; }
private int getPathAttributeStatus( String pathAttribute, String sourcePath ) { if (!CookieProperties.isPathMatchingStrict() || sourcePath.length() == 0 || sourcePath.startsWith( pathAttribute )) { return CookieListener.ACCEPTED; } else { return CookieListener.PATH_NOT_PREFIX; } }