001/******************************************************************************* 002 * Copyright 2017 The MIT Internet Trust Consortium 003 * 004 * Portions copyright 2011-2013 The MITRE Corporation 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 *******************************************************************************/ 018package org.mitre.openid.connect.web; 019 020import java.util.Map; 021 022import org.mitre.openid.connect.service.StatsService; 023import org.springframework.beans.factory.annotation.Autowired; 024import org.springframework.security.access.prepost.PreAuthorize; 025import org.springframework.stereotype.Controller; 026import org.springframework.ui.ModelMap; 027import org.springframework.web.bind.annotation.RequestMapping; 028 029/** 030 * @author Michael Jett <mjett@mitre.org> 031 */ 032 033@Controller 034public class RootController { 035 036 public static final String API_URL = "api"; 037 038 @Autowired 039 private StatsService statsService; 040 041 @RequestMapping({"", "home", "index"}) 042 public String showHomePage(ModelMap m) { 043 return "home"; 044 } 045 046 @RequestMapping({"about", "about/"}) 047 public String showAboutPage(ModelMap m) { 048 return "about"; 049 } 050 051 @RequestMapping({"stats", "stats/"}) 052 public String showStatsPage(ModelMap m) { 053 Map<String, Integer> summary = statsService.getSummaryStats(); 054 055 m.put("statsSummary", summary); 056 return "stats"; 057 } 058 059 @RequestMapping({"contact", "contact/"}) 060 public String showContactPage(ModelMap m) { 061 return "contact"; 062 } 063 064 @PreAuthorize("hasRole('ROLE_USER')") 065 @RequestMapping("manage/**") 066 public String showClientManager(ModelMap m) { 067 return "manage"; 068 } 069 070 public StatsService getStatsService() { 071 return statsService; 072 } 073 074 public void setStatsService(StatsService statsService) { 075 this.statsService = statsService; 076 } 077 078}