aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/jdisc/http/filter/JDiscCookieWrapper.java
blob: f86a9b81155660d6a663efab3f6f596e997e49de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.http.filter;

import com.yahoo.jdisc.http.Cookie;

import java.util.concurrent.TimeUnit;

/**
 * Wrapper of Cookie.
 *
 * @author Tejal Knot
 *
 */
public class JDiscCookieWrapper {

    private Cookie cookie;

    protected JDiscCookieWrapper(Cookie cookie) {
        this.cookie = cookie;
    }

    public static JDiscCookieWrapper wrap(Cookie cookie) {
        return new JDiscCookieWrapper(cookie);
    }

    public String getDomain() {
        return cookie.getDomain();
    }

    public int getMaxAge() {
        return cookie.getMaxAge(TimeUnit.SECONDS);
    }

    public String getName() {
        return cookie.getName();
    }

    public String getPath() {
        return cookie.getPath();
    }

    public boolean getSecure() {
        return cookie.isSecure();
    }

    public String getValue() {
        return cookie.getValue();
    }

    public void setDomain(String pattern) {
        cookie.setDomain(pattern);
    }

    public void setMaxAge(int expiry) {
        cookie.setMaxAge(expiry, TimeUnit.SECONDS);
    }

    public void setPath(String uri) {
        cookie.setPath(uri);
    }

    public void setSecure(boolean flag) {
      cookie.setSecure(flag);
    }

    public void setValue(String newValue) {
       cookie.setValue(newValue);
    }

    /**
     * Return com.yahoo.jdisc.http.Cookie
     *
     * @return - cookie
     */
    public Cookie getCookie() {
       return cookie;
    }

}