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  import org.slf4j.Logger;
24  import org.slf4j.LoggerFactory;
25  
26  import java.net.URL;
27  import java.util.ArrayList;
28  import java.util.HashMap;
29  import java.util.List;
30  import java.util.Map;
31  import java.util.Properties;
32  
33  public class TobagoConfigFragment {
34  
35    private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigFragment.class);
36  
37    private String name;
38    private List<String> before;
39    private List<String> after;
40  
41    private List<String> supportedThemeNames;
42    private String defaultThemeName;
43    private RenderersConfig renderersConfig;
44    private Boolean createSessionSecret;
45    private Boolean checkSessionSecret;
46    private Boolean preventFrameAttacks;
47    private ContentSecurityPolicy contentSecurityPolicy;
48    private Boolean checkSecurityAnnotations;
49    private Boolean setNosniffHeader;
50    private List<ThemeImpl> themeDefinitions;
51    private URL url;
52    private String sanitizerClass;
53    private Properties sanitizerProperties;
54    private Map<String, String> mimeTypes;
55  
56    public TobagoConfigFragment() {
57      before = new ArrayList<String>();
58      after = new ArrayList<String>();
59      supportedThemeNames = new ArrayList<String>();
60      themeDefinitions = new ArrayList<ThemeImpl>();
61      mimeTypes = new HashMap<String, String>();
62    }
63  
64    public void addSupportedThemeName(final String name) {
65      supportedThemeNames.add(name);
66    }
67  
68    public List<String> getSupportedThemeNames() {
69      return supportedThemeNames;
70    }
71  
72    public String getDefaultThemeName() {
73      return defaultThemeName;
74    }
75  
76    public void setDefaultThemeName(final String defaultThemeName) {
77      this.defaultThemeName = defaultThemeName;
78    }
79  
80    public RenderersConfig getRenderersConfig() {
81      return renderersConfig;
82    }
83  
84    public void setRenderersConfig(final RenderersConfig renderersConfig) {
85      this.renderersConfig = renderersConfig;
86    }
87  
88    public String getName() {
89      return name;
90    }
91  
92    public void setName(final String name) {
93      this.name = name;
94    }
95  
96    public List<String> getBefore() {
97      return before;
98    }
99  
100   public void addBefore(final String name) {
101     before.add(name);
102   }
103 
104   public List<String> getAfter() {
105     return after;
106   }
107 
108   public void addAfter(final String name) {
109     after.add(name);
110   }
111 
112   public void addThemeDefinition(final ThemeImpl theme) {
113     themeDefinitions.add(theme);
114   }
115 
116   public List<ThemeImpl> getThemeDefinitions() {
117     return themeDefinitions;
118   }
119 
120   public Boolean getCreateSessionSecret() {
121     return createSessionSecret;
122   }
123 
124   public void setCreateSessionSecret(final String createSessionSecret) {
125     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
126   }
127 
128   public Boolean getCheckSessionSecret() {
129     return checkSessionSecret;
130   }
131 
132   public void setCheckSessionSecret(final String checkSessionSecret) {
133     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
134   }
135 
136   public Boolean getPreventFrameAttacks() {
137     return preventFrameAttacks;
138   }
139 
140   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
141     this.preventFrameAttacks = preventFrameAttacks;
142   }
143 
144   public ContentSecurityPolicy getContentSecurityPolicy() {
145     return contentSecurityPolicy;
146   }
147 
148   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
149     this.contentSecurityPolicy = contentSecurityPolicy;
150   }
151 
152   public Boolean getCheckSecurityAnnotations() {
153     return checkSecurityAnnotations;
154   }
155 
156   public void setCheckSecurityAnnotations(final Boolean checkSecurityAnnotations) {
157     this.checkSecurityAnnotations = checkSecurityAnnotations;
158   }
159 
160   public Boolean getSetNosniffHeader() {
161     return setNosniffHeader;
162   }
163 
164   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
165     this.setNosniffHeader = setNosniffHeader;
166   }
167 
168   public URL getUrl() {
169     return url;
170   }
171 
172   public void setUrl(final URL url) {
173     this.url = url;
174   }
175 
176   public String getSanitizerClass() {
177     return sanitizerClass;
178   }
179 
180   public void setSanitizerClass(String sanitizerClass) {
181     this.sanitizerClass = sanitizerClass;
182   }
183 
184   public Properties getSanitizerProperties() {
185     return sanitizerProperties;
186   }
187 
188   public void setSanitizerProperties(Properties sanitizerProperties) {
189     this.sanitizerProperties = sanitizerProperties;
190   }
191 
192   public void addMimeType(String extension, String type) {
193     this.mimeTypes.put(extension, type);
194   }
195 
196   public Map<String, String> getMimeTypes() {
197     return mimeTypes;
198   }
199 
200   @Override
201   public String toString() {
202     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
203   }
204 }