15cd4c537c49802579a65ab3ce2ae102db6e5601
[sdc.git] /
1 package org.openecomp.sdc.securityutil.filters;
2
3
4 import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration;
5
6 import javax.servlet.http.Cookie;
7 import java.util.ArrayList;
8 import java.util.Arrays;
9 import java.util.List;
10
11 public class SampleFilter extends SessionValidationFilter {
12
13     private static class Configuration implements ISessionValidationFilterConfiguration {
14
15         private static Configuration instance;
16
17         private String securityKey;
18         private long maxSessionTimeOut;
19         private long sessionIdleTimeOut;
20         private String redirectURL;
21         private List<String> excludedUrls;
22
23         private String cookieName;
24         private String cookieDomain;
25         private String cookiePath;
26         private boolean isCookieHttpOnly;
27
28         private Configuration() {
29             //security key should be exactly 16 characters long clear text and then encoded to base64
30             this.securityKey = "AGLDdG4D04BKm2IxIWEr8o==";
31             this.maxSessionTimeOut = 24*60*60*1000;
32             this.sessionIdleTimeOut = 60*60*1000;
33             this.redirectURL = "https://www.e-access.att.com/ecomp_portal_ist/ecompportal/process_csp";
34             this.excludedUrls = new ArrayList<>(Arrays.asList("/config","/configmgr","/rest","/kibanaProxy","/healthcheck","/upload.*"));
35
36             this.cookieName = "kuku";
37             this.cookieDomain = "";
38             this.cookiePath = "/";
39             this.isCookieHttpOnly = true;
40         }
41
42         public void setSecurityKey(String securityKey) {
43             this.securityKey = securityKey;
44         }
45
46         public void setMaxSessionTimeOut(long maxSessionTimeOut) {
47             this.maxSessionTimeOut = maxSessionTimeOut;
48         }
49
50         public void setCookieName(String cookieName) {
51             this.cookieName = cookieName;
52         }
53
54         public void setRedirectURL(String redirectURL) {
55             this.redirectURL = redirectURL;
56         }
57
58         public void setExcludedUrls(List<String> excludedUrls) {
59             this.excludedUrls = excludedUrls;
60         }
61
62         public  static Configuration getInstance(){
63             if (instance == null ){
64                 instance =  new Configuration();
65             }
66             return instance;
67         }
68
69         @Override
70         public String getSecurityKey() {
71             return securityKey;
72         }
73
74         @Override
75         public long getMaxSessionTimeOut() {
76             return maxSessionTimeOut;
77         }
78
79         @Override
80         public long getSessionIdleTimeOut() {
81             return sessionIdleTimeOut;
82         }
83
84         @Override
85         public String getCookieName() {
86             return cookieName;
87         }
88
89         @Override
90         public String getCookieDomain() {
91             return cookieDomain;
92         }
93
94         @Override
95         public String getCookiePath() {
96             return cookiePath;
97         }
98
99         @Override
100         public boolean isCookieHttpOnly() {
101             return isCookieHttpOnly;
102         }
103
104         @Override
105         public String getRedirectURL() {
106             return redirectURL;
107         }
108
109         @Override
110         public List<String> getExcludedUrls() {
111             return excludedUrls;
112         }
113     }
114
115     @Override
116     public ISessionValidationFilterConfiguration getFilterConfiguration() {
117         return Configuration.getInstance();
118     }
119
120     @Override
121     protected Cookie addRoleToCookie(Cookie updatedCookie) {
122         return updatedCookie;
123     }
124
125     @Override
126     protected boolean isRoleValid(Cookie cookie) {
127         return true;
128     }
129
130 }
131
132