本文整理汇总了Java中org.apache.http.cookie.CookieAttributeHandler类的典型用法代码示例。如果您正苦于以下问题:Java CookieAttributeHandler类的具体用法?Java CookieAttributeHandler怎么用?Java CookieAttributeHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CookieAttributeHandler类属于org.apache.http.cookie包,在下文中一共展示了CookieAttributeHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testBasicDomainValidate2
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testBasicDomainValidate2() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain("somehost");
h.validate(cookie, origin);
cookie.setDomain("otherhost");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestBasicCookieAttribHandlers.java
示例2: testBasicDomainMatch2
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testBasicDomainMatch2() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new BasicDomainHandler();
cookie.setDomain("somedomain.com");
cookie.setAttribute(ClientCookie.DOMAIN_ATTR, "somedomain.com");
Assert.assertTrue(h.match(cookie, origin));
cookie.setDomain(".somedomain.com");
Assert.assertTrue(h.match(cookie, origin));
cookie.setDomain(null);
Assert.assertFalse(h.match(cookie, origin));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:TestBasicCookieAttribHandlers.java
示例3: testBasicSecureMatch
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testBasicSecureMatch() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new BasicSecureHandler();
final CookieOrigin origin1 = new CookieOrigin("somehost", 80, "/stuff", false);
cookie.setSecure(false);
Assert.assertTrue(h.match(cookie, origin1));
cookie.setSecure(true);
Assert.assertFalse(h.match(cookie, origin1));
final CookieOrigin origin2 = new CookieOrigin("somehost", 80, "/stuff", true);
cookie.setSecure(false);
Assert.assertTrue(h.match(cookie, origin2));
cookie.setSecure(true);
Assert.assertTrue(h.match(cookie, origin2));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestBasicCookieAttribHandlers.java
示例4: testParseExpiry
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testParseExpiry() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new LaxExpiresHandler();
h.parse(cookie, "1:0:12 8-jan-2012");
final Date expiryDate = cookie.getExpiryDate();
Assert.assertNotNull(expiryDate);
final Calendar c = Calendar.getInstance();
c.setTimeZone(LaxExpiresHandler.UTC);
c.setTime(expiryDate);
Assert.assertEquals(2012, c.get(Calendar.YEAR));
Assert.assertEquals(Calendar.JANUARY, c.get(Calendar.MONTH));
Assert.assertEquals(8, c.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(1, c.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, c.get(Calendar.MINUTE));
Assert.assertEquals(12, c.get(Calendar.SECOND));
Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java
示例5: testParseExpiryFunnyTime
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testParseExpiryFunnyTime() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new LaxExpiresHandler();
h.parse(cookie, "1:59:00blah; 8-feb-2000");
final Date expiryDate = cookie.getExpiryDate();
Assert.assertNotNull(expiryDate);
final Calendar c = Calendar.getInstance();
c.setTimeZone(LaxExpiresHandler.UTC);
c.setTime(expiryDate);
Assert.assertEquals(2000, c.get(Calendar.YEAR));
Assert.assertEquals(Calendar.FEBRUARY, c.get(Calendar.MONTH));
Assert.assertEquals(8, c.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(1, c.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(59, c.get(Calendar.MINUTE));
Assert.assertEquals(0, c.get(Calendar.SECOND));
Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java
示例6: testParseExpiryFunnyDayOfMonth
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testParseExpiryFunnyDayOfMonth() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new LaxExpiresHandler();
h.parse(cookie, "12:00:00 8blah;mar;1880");
final Date expiryDate = cookie.getExpiryDate();
Assert.assertNotNull(expiryDate);
final Calendar c = Calendar.getInstance();
c.setTimeZone(LaxExpiresHandler.UTC);
c.setTime(expiryDate);
Assert.assertEquals(1880, c.get(Calendar.YEAR));
Assert.assertEquals(Calendar.MARCH, c.get(Calendar.MONTH));
Assert.assertEquals(8, c.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(12, c.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(0, c.get(Calendar.MINUTE));
Assert.assertEquals(0, c.get(Calendar.SECOND));
Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java
示例7: testParseExpiryFunnyMonth
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testParseExpiryFunnyMonth() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new LaxExpiresHandler();
h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008");
final Date expiryDate = cookie.getExpiryDate();
Assert.assertNotNull(expiryDate);
final Calendar c = Calendar.getInstance();
c.setTimeZone(LaxExpiresHandler.UTC);
c.setTime(expiryDate);
Assert.assertEquals(2008, c.get(Calendar.YEAR));
Assert.assertEquals(Calendar.APRIL, c.get(Calendar.MONTH));
Assert.assertEquals(1, c.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(23, c.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(59, c.get(Calendar.MINUTE));
Assert.assertEquals(59, c.get(Calendar.SECOND));
Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java
示例8: testParseExpiryFunnyYear
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testParseExpiryFunnyYear() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieAttributeHandler h = new LaxExpiresHandler();
h.parse(cookie, "23:59:59; 1-Apr-2008blah");
final Date expiryDate = cookie.getExpiryDate();
Assert.assertNotNull(expiryDate);
final Calendar c = Calendar.getInstance();
c.setTimeZone(LaxExpiresHandler.UTC);
c.setTime(expiryDate);
Assert.assertEquals(2008, c.get(Calendar.YEAR));
Assert.assertEquals(Calendar.APRIL, c.get(Calendar.MONTH));
Assert.assertEquals(1, c.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(23, c.get(Calendar.HOUR_OF_DAY));
Assert.assertEquals(59, c.get(Calendar.MINUTE));
Assert.assertEquals(59, c.get(Calendar.SECOND));
Assert.assertEquals(0, c.get(Calendar.MILLISECOND));
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestLaxCookieAttribHandlers.java
示例9: testRFC2109DomainValidate3
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testRFC2109DomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
final CookieAttributeHandler h = new RFC2109DomainHandler();
cookie.setDomain(".a.com");
h.validate(cookie, origin);
cookie.setDomain(".com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestRFC2109CookieAttribHandlers.java
示例10: testRFC2109VersionValidate
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testRFC2109VersionValidate() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false);
final CookieAttributeHandler h = new RFC2109VersionHandler();
cookie.setVersion(12);
h.validate(cookie, origin);
cookie.setVersion(-12);
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException must have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestRFC2109CookieAttribHandlers.java
示例11: testNetscapeDomainValidate1
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testNetscapeDomainValidate1() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain("somehost");
h.validate(cookie, origin);
cookie.setDomain("otherhost");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestNetscapeCookieAttribHandlers.java
示例12: testNetscapeDomainValidate3
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testNetscapeDomainValidate3() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.com", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(".a.com");
h.validate(cookie, origin);
cookie.setDomain(".com");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestNetscapeCookieAttribHandlers.java
示例13: testNetscapeDomainValidate4
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
@Test
public void testNetscapeDomainValidate4() throws Exception {
final BasicClientCookie cookie = new BasicClientCookie("name", "value");
final CookieOrigin origin = new CookieOrigin("www.a.b.c", 80, "/", false);
final CookieAttributeHandler h = new NetscapeDomainHandler();
cookie.setDomain(".a.b.c");
h.validate(cookie, origin);
cookie.setDomain(".b.c");
try {
h.validate(cookie, origin);
Assert.fail("MalformedCookieException should have been thrown");
} catch (final MalformedCookieException ex) {
// expected
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestNetscapeCookieAttribHandlers.java
示例14: parse
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
for (HeaderElement headerelement : elems) {
String name = headerelement.getName();
String value = headerelement.getValue();
if (name == null || name.length() == 0) {
throw new MalformedCookieException("Cookie name may not be empty");
}
BasicClientCookie cookie = new BasicClientCookie(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));
// cycle through the parameters
NameValuePair[] attribs = headerelement.getParameters();
for (int j = attribs.length - 1; j >= 0; j--) {
NameValuePair attrib = attribs[j];
String s = attrib.getName().toLowerCase(Locale.ENGLISH);
cookie.setAttribute(s, attrib.getValue());
CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {
handler.parse(cookie, attrib.getValue());
}
}
cookies.add(cookie);
}
return cookies;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:CookieSpecBase.java
示例15: validate
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
public void validate(final Cookie cookie, final CookieOrigin origin)
throws MalformedCookieException {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
for (CookieAttributeHandler handler: getAttribHandlers()) {
handler.validate(cookie, origin);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:CookieSpecBase.java
示例16: match
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
public boolean match(final Cookie cookie, final CookieOrigin origin) {
if (cookie == null) {
throw new IllegalArgumentException("Cookie may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
for (CookieAttributeHandler handler: getAttribHandlers()) {
if (!handler.match(cookie, origin)) {
return false;
}
}
return true;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:CookieSpecBase.java
示例17: registerAttribHandler
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
public void registerAttribHandler(
final String name, final CookieAttributeHandler handler) {
if (name == null) {
throw new IllegalArgumentException("Attribute name may not be null");
}
if (handler == null) {
throw new IllegalArgumentException("Attribute handler may not be null");
}
this.attribHandlerMap.put(name, handler);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AbstractCookieSpec.java
示例18: getAttribHandler
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
/**
* Gets attribute handler {@link CookieAttributeHandler} for the
* given attribute.
*
* @param name attribute name. e.g. Domain, Path, etc.
* @throws IllegalStateException if handler not found for the
* specified attribute.
*/
protected CookieAttributeHandler getAttribHandler(final String name) {
CookieAttributeHandler handler = findAttribHandler(name);
if (handler == null) {
throw new IllegalStateException("Handler not registered for " +
name + " attribute.");
} else {
return handler;
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AbstractCookieSpec.java
示例19: getAttribHandler
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
/**
* Gets attribute handler {@link CookieAttributeHandler} for the
* given attribute.
*
* @param name attribute name. e.g. Domain, Path, etc.
* @throws IllegalStateException if handler not found for the
* specified attribute.
*/
protected CookieAttributeHandler getAttribHandler(final String name) {
final CookieAttributeHandler handler = findAttribHandler(name);
if (handler == null) {
throw new IllegalStateException("Handler not registered for " +
name + " attribute.");
} else {
return handler;
}
}
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:18,代码来源:AbstractCookieSpecHC4.java
示例20: parse
import org.apache.http.cookie.CookieAttributeHandler; //导入依赖的package包/类
protected List<Cookie> parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
final List<Cookie> cookies = new ArrayList<Cookie>(elems.length);
for (final HeaderElement headerelement : elems) {
final String name = headerelement.getName();
final String value = headerelement.getValue();
if (name == null || name.length() == 0) {
throw new MalformedCookieException("Cookie name may not be empty");
}
final BasicClientCookieHC4 cookie = new BasicClientCookieHC4(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));
// cycle through the parameters
final NameValuePair[] attribs = headerelement.getParameters();
for (int j = attribs.length - 1; j >= 0; j--) {
final NameValuePair attrib = attribs[j];
final String s = attrib.getName().toLowerCase(Locale.ENGLISH);
cookie.setAttribute(s, attrib.getValue());
final CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {
handler.parse(cookie, attrib.getValue());
}
}
cookies.add(cookie);
}
return cookies;
}
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:32,代码来源:CookieSpecBaseHC4.java
注:本文中的org.apache.http.cookie.CookieAttributeHandler类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论