001/******************************************************************************* 002 * Copyright 2014 The MITRE Corporation 003 * and the MIT Kerberos and Internet Trust Consortium 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 ******************************************************************************/ 017package org.mitre.openid.connect.config; 018 019import javax.annotation.PostConstruct; 020 021import org.slf4j.Logger; 022import org.slf4j.LoggerFactory; 023import org.springframework.beans.factory.BeanCreationException; 024import org.springframework.util.StringUtils; 025 026 027 028/** 029 * Bean to hold configuration information that must be injected into various parts 030 * of our application. Set all of the properties here, and autowire a reference 031 * to this bean if you need access to any configuration properties. 032 * 033 * @author AANGANES 034 * 035 */ 036public class ConfigurationPropertiesBean { 037 038 private static Logger logger = LoggerFactory.getLogger(ConfigurationPropertiesBean.class); 039 040 private String issuer; 041 042 private String topbarTitle; 043 044 private String logoImageUrl; 045 046 private Long regTokenLifeTime; 047 048 private boolean forceHttps = false; 049 050 public ConfigurationPropertiesBean() { 051 052 } 053 054 /** 055 * Endpoints protected by TLS must have https scheme in the URI. 056 * @throws HttpsUrlRequiredException 057 */ 058 @PostConstruct 059 public void checkForHttps() { 060 if (!StringUtils.startsWithIgnoreCase(issuer, "https")) { 061 if (this.forceHttps) { 062 logger.error("Configured issuer url is not using https scheme. Server will be shut down!"); 063 throw new BeanCreationException("Issuer is not using https scheme as required: " + issuer); 064 } 065 else { 066 logger.warn("Configured issuer url is not using https scheme."); 067 } 068 } 069 } 070 071 /** 072 * @return the issuer baseUrl 073 */ 074 public String getIssuer() { 075 return issuer; 076 } 077 078 /** 079 * @param iss the issuer to set 080 */ 081 public void setIssuer(String iss) { 082 issuer = iss; 083 } 084 085 /** 086 * @return the topbarTitle 087 */ 088 public String getTopbarTitle() { 089 return topbarTitle; 090 } 091 092 /** 093 * @param topbarTitle the topbarTitle to set 094 */ 095 public void setTopbarTitle(String topbarTitle) { 096 this.topbarTitle = topbarTitle; 097 } 098 099 /** 100 * @return the logoImageUrl 101 */ 102 public String getLogoImageUrl() { 103 return logoImageUrl; 104 } 105 106 /** 107 * @param logoImageUrl the logoImageUrl to set 108 */ 109 public void setLogoImageUrl(String logoImageUrl) { 110 this.logoImageUrl = logoImageUrl; 111 } 112 113 /** 114 * @return the regTokenLifeTime 115 */ 116 public Long getRegTokenLifeTime() { 117 return regTokenLifeTime; 118 } 119 120 /** 121 * @param regTokenLifeTime the registration token lifetime to set in seconds 122 */ 123 public void setRegTokenLifeTime(Long regTokenLifeTime) { 124 this.regTokenLifeTime = regTokenLifeTime; 125 } 126 127 public boolean isForceHttps() { 128 return forceHttps; 129 } 130 131 public void setForceHttps(boolean forceHttps) { 132 this.forceHttps = forceHttps; 133 } 134}