static Object newObjectInstance(String className) { try { return ClassLoaderUtil.newInstance(className, RelyingParty.class); } catch (Exception e) { throw new RuntimeException(e); } }
/** * Load the configured mappings from the properties file located at the given {@code resourceLoc}. */ public static void load(String resourceLoc, Map<String, String> mappings) { URL resource = ClassLoaderUtil.getResource(resourceLoc, IdentifierSelectUserCache.class); if (resource == null) return; // throw new IllegalStateException("resource: " + resourceLoc + " not found"); Properties props = new Properties(); try { props.load(resource.openStream()); } catch (IOException e) { // throw new RuntimeException(e); return; } String[] providers = Delim.COMMA.split(props.getProperty("providers")); for (String p : providers) { String openIdServer = props.getProperty(p + ".openid_server"); if (openIdServer != null) { for (int i = 0; ; i++) { String id = props.getProperty(p + ".identifier." + i); if (id == null) break; mappings.put(id, openIdServer); } } } }
/** * This method is called by the servlet container to configure this filter; The init parameter * "forwardUri" is required. The relying party used will be the default {@link * RelyingParty#getInstance() instance} if it is not found in the servlet context attributes. */ public void init(FilterConfig config) throws ServletException { _forwardUri = config.getInitParameter("forwardUri"); if (_forwardUri == null) throw new ServletException("forwardUri must not be null."); // resolve from ServletContext _relyingParty = (RelyingParty) config.getServletContext().getAttribute(RelyingParty.class.getName()); // default config if null if (_relyingParty == null) _relyingParty = RelyingParty.getInstance(); String forwardUriHandlerParam = config.getInitParameter("forwardUriHandler"); if (forwardUriHandlerParam != null) { try { _forwardHandler = ClassLoaderUtil.newInstance(forwardUriHandlerParam, OpenIdServletFilter.class); } catch (Exception e) { throw new ServletException(e); } } else _forwardHandler = DEFAULT_FORWARD_URI_HANDLER; }
static URL getResource(String resource) { return ClassLoaderUtil.getResource(resource, RelyingParty.class); }