View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.config;
21  
22  import org.apache.myfaces.tobago.context.ThemeImpl;
23  
24  import java.net.URL;
25  import java.util.ArrayList;
26  import java.util.HashMap;
27  import java.util.List;
28  import java.util.Map;
29  import java.util.Properties;
30  
31  public class TobagoConfigFragment {
32  
33    private String name;
34    private List<String> before;
35    private List<String> after;
36  
37    private List<String> supportedThemeNames;
38    private String defaultThemeName;
39    private Boolean createSessionSecret;
40    private Boolean checkSessionSecret;
41    private Boolean preventFrameAttacks;
42    private ContentSecurityPolicy contentSecurityPolicy;
43    private SecurityAnnotation securityAnnotation;
44    private Boolean setNosniffHeader;
45    private List<ThemeImpl> themeDefinitions;
46    private URL url;
47    private String sanitizerClass;
48    private Boolean decodeLineFeed;
49    private Properties sanitizerProperties;
50    private Map<String, String> mimeTypes;
51  
52    public TobagoConfigFragment() {
53      before = new ArrayList<>();
54      after = new ArrayList<>();
55      supportedThemeNames = new ArrayList<>();
56      themeDefinitions = new ArrayList<>();
57      mimeTypes = new HashMap<>();
58    }
59  
60    public void addSupportedThemeName(final String supportedThemeName) {
61      supportedThemeNames.add(supportedThemeName);
62    }
63  
64    public List<String> getSupportedThemeNames() {
65      return supportedThemeNames;
66    }
67  
68    public String getDefaultThemeName() {
69      return defaultThemeName;
70    }
71  
72    public void setDefaultThemeName(final String defaultThemeName) {
73      this.defaultThemeName = defaultThemeName;
74    }
75  
76    public String getName() {
77      return name;
78    }
79  
80    public void setName(final String name) {
81      this.name = name;
82    }
83  
84    public List<String> getBefore() {
85      return before;
86    }
87  
88    public void addBefore(final String nameBefore) {
89      before.add(nameBefore);
90    }
91  
92    public List<String> getAfter() {
93      return after;
94    }
95  
96    public void addAfter(final String nameAfter) {
97      after.add(nameAfter);
98    }
99  
100   public void addThemeDefinition(final ThemeImpl theme) {
101     themeDefinitions.add(theme);
102   }
103 
104   public List<ThemeImpl> getThemeDefinitions() {
105     return themeDefinitions;
106   }
107 
108   public Boolean getCreateSessionSecret() {
109     return createSessionSecret;
110   }
111 
112   public void setCreateSessionSecret(final String createSessionSecret) {
113     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
114   }
115 
116   public Boolean getCheckSessionSecret() {
117     return checkSessionSecret;
118   }
119 
120   public void setCheckSessionSecret(final String checkSessionSecret) {
121     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
122   }
123 
124   public Boolean getPreventFrameAttacks() {
125     return preventFrameAttacks;
126   }
127 
128   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
129     this.preventFrameAttacks = preventFrameAttacks;
130   }
131 
132   public ContentSecurityPolicy getContentSecurityPolicy() {
133     return contentSecurityPolicy;
134   }
135 
136   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
137     this.contentSecurityPolicy = contentSecurityPolicy;
138   }
139 
140   public SecurityAnnotation getSecurityAnnotation() {
141     return securityAnnotation;
142   }
143 
144   public void setSecurityAnnotation(final SecurityAnnotation securityAnnotation) {
145     this.securityAnnotation = securityAnnotation;
146   }
147 
148   public Boolean getSetNosniffHeader() {
149     return setNosniffHeader;
150   }
151 
152   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
153     this.setNosniffHeader = setNosniffHeader;
154   }
155 
156   public URL getUrl() {
157     return url;
158   }
159 
160   public void setUrl(final URL url) {
161     this.url = url;
162   }
163 
164   public String getSanitizerClass() {
165     return sanitizerClass;
166   }
167 
168   public void setSanitizerClass(final String sanitizerClass) {
169     this.sanitizerClass = sanitizerClass;
170   }
171 
172   public Properties getSanitizerProperties() {
173     return sanitizerProperties;
174   }
175 
176   public void setSanitizerProperties(final Properties sanitizerProperties) {
177     this.sanitizerProperties = sanitizerProperties;
178   }
179 
180   public Boolean getDecodeLineFeed() {
181     return decodeLineFeed;
182   }
183 
184   public void setDecodeLineFeed(final Boolean decodeLineFeed) {
185     this.decodeLineFeed = decodeLineFeed;
186   }
187 
188   public void addMimeType(final String extension, final String type) {
189     this.mimeTypes.put(extension, type);
190   }
191 
192   public Map<String, String> getMimeTypes() {
193     return mimeTypes;
194   }
195 
196   @Override
197   public String toString() {
198     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
199   }
200 }