1 package edu.internet2.middleware.shibboleth.wayf;
3 import java.util.Enumeration;
4 import java.util.HashSet;
5 import java.util.StringTokenizer;
7 import javax.servlet.ServletContext;
10 * Class used by the WAYF service to determine runtime options
11 * Most of the fields of this class should have reasonable defaults set
12 * @author Walter Hoehn
15 public class WayfConfig {
17 private static WayfOrigins wd;
18 private static String location;
19 private static String logoLocation = "images/internet2.gif";
20 private static String supportContact = "mailto:shib-support@internet2.org";
21 private static String helpText =
22 "In order to fulfill the request for the web resource you "
23 + "have just chosen, information must first be obtained from "
24 + "your home institution. Please select the institution with "
25 + "which you are affiliated.";
26 private static String searchResultEmptyText =
27 "No institution found that matches your search " + "criteria, please try again.";
28 private static HashSet ignoredForMatch = new HashSet();
30 private static String cache = "SESSION";
32 private static ServletContext servletContext;
35 * Constructor for WayfConfig.
43 * @return Returns a WayfOrigins
45 public static WayfOrigins getWAYFData() {
51 * @param wd The wd to set
53 public void setWAYFData(WayfOrigins wd) {
58 * Gets the searchResultEmptyText.
59 * @return Returns a String
61 public static String getSearchResultEmptyText() {
62 return searchResultEmptyText;
66 * Sets the searchResultEmptyText.
67 * @param searchResultEmptyText The searchResultEmptyText to set
69 public void setSearchResultEmptyText(String searchResultEmptyText) {
70 WayfConfig.searchResultEmptyText = searchResultEmptyText;
75 * @return Returns a String
77 public static String getHelpText() {
83 * @param helpText The helpText to set
85 public void setHelpText(String helpText) {
86 WayfConfig.helpText = helpText;
90 * Gets the supportContact.
91 * @return Returns a String
93 public static String getSupportContact() {
94 return supportContact;
98 * Sets the supportContact.
99 * @param supportContact The supportContact to set
101 public void setSupportContact(String supportContact) {
102 WayfConfig.supportContact = supportContact;
106 * Gets the logoLocation.
107 * @return Returns a String
109 public static String getLogoLocation() {
114 * Sets the logoLocation.
115 * @param logoLocation The logoLocation to set
117 public void setLogoLocation(String logoLocation) {
118 WayfConfig.logoLocation = logoLocation;
123 * @return Returns a String
125 public static String getLocation() {
131 * @param location The location to set
133 public void setLocation(String location) {
134 WayfConfig.location = location;
138 * Determines if a particular string token should be used for matching when a user searches for origins.
139 * @param str The string to lookup
141 public static boolean isIgnoredForMatch(String str) {
143 if (ignoredForMatch.contains(str.toLowerCase())) {
151 * Sets the tokens that should be ignored when a user searches for an origin site.
152 * @param s The ignored tokens are passed as a single string, each separated by whitespace
154 public void addIgnoredForMatch(String s) {
156 ignoredForMatch.add(s.toLowerCase());
160 * Gets the servletContext.
161 * @return Returns a ServletContext
163 public static ServletContext getServletContext() {
164 return servletContext;
168 * Sets the servletContext.
169 * @param servletContext The servletContext to set
171 public static void setServletContext(ServletContext servletContext) {
172 WayfConfig.servletContext = servletContext;
177 * @return Returns a String
179 public static String getCache() {
185 * @param cache The cache to set
187 public void setCache(String cache) {
188 if (cache.toUpperCase().equals("NONE")
189 || cache.toUpperCase().equals("SESSION")
190 || cache.toUpperCase().equals("COOKIES")) {
191 WayfConfig.cache = cache.toUpperCase();
193 getServletContext().log("Cache type :" + cache + ": not recognized, using default.");