ServerConfigInterceptor.java

  1. /*******************************************************************************
  2.  * Copyright 2017 The MIT Internet Trust Consortium
  3.  *
  4.  * Portions copyright 2011-2013 The MITRE Corporation
  5.  *
  6.  * Licensed under the Apache License, Version 2.0 (the "License");
  7.  * you may not use this file except in compliance with the License.
  8.  * 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, software
  13.  * distributed under the License is distributed on an "AS IS" BASIS,
  14.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15.  * See the License for the specific language governing permissions and
  16.  * limitations under the License.
  17.  *******************************************************************************/
  18. /**
  19.  *
  20.  */
  21. package org.mitre.openid.connect.web;

  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;

  24. import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
  25. import org.mitre.openid.connect.config.UIConfiguration;
  26. import org.springframework.beans.factory.annotation.Autowired;
  27. import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

  28. /**
  29.  *
  30.  * Injects the server configuration bean into the request context.
  31.  * This allows JSPs and the like to call "config.logoUrl" among others.
  32.  *
  33.  * @author jricher
  34.  *
  35.  */
  36. public class ServerConfigInterceptor extends HandlerInterceptorAdapter {

  37.     @Autowired
  38.     private ConfigurationPropertiesBean config;

  39.     @Autowired
  40.     private UIConfiguration ui;

  41.     @Override
  42.     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
  43.         request.setAttribute("config", config);
  44.         request.setAttribute("ui", ui);
  45.         return true;
  46.     }

  47. }