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 *******************************************************************************/ 018/** 019 * 020 */ 021package org.mitre.openid.connect.client.service.impl; 022 023import javax.annotation.PostConstruct; 024import javax.servlet.http.HttpServletRequest; 025 026import org.mitre.openid.connect.client.model.IssuerServiceResponse; 027import org.mitre.openid.connect.client.service.IssuerService; 028 029import com.google.common.base.Strings; 030 031/** 032 * @author jricher 033 * 034 */ 035public class StaticSingleIssuerService implements IssuerService { 036 037 private String issuer; 038 039 /** 040 * @return the issuer 041 */ 042 public String getIssuer() { 043 return issuer; 044 } 045 046 /** 047 * @param issuer the issuer to set 048 */ 049 public void setIssuer(String issuer) { 050 this.issuer = issuer; 051 } 052 053 /** 054 * Always returns the configured issuer URL 055 * 056 * @see org.mitre.openid.connect.client.service.IssuerService#getIssuer(javax.servlet.http.HttpServletRequest) 057 */ 058 @Override 059 public IssuerServiceResponse getIssuer(HttpServletRequest request) { 060 return new IssuerServiceResponse(getIssuer(), null, null); 061 } 062 063 @PostConstruct 064 public void afterPropertiesSet() { 065 066 if (Strings.isNullOrEmpty(issuer)) { 067 throw new IllegalArgumentException("Issuer must not be null or empty."); 068 } 069 070 } 071 072}