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 java.util.HashMap;
024import java.util.Map;
025
026import javax.servlet.http.HttpServletRequest;
027
028import org.mitre.oauth2.model.RegisteredClient;
029import org.mitre.openid.connect.client.service.AuthRequestOptionsService;
030import org.mitre.openid.connect.config.ServerConfiguration;
031
032/**
033 *
034 * Always returns the same set of options.
035 *
036 * @author jricher
037 *
038 */
039public class StaticAuthRequestOptionsService implements AuthRequestOptionsService {
040
041        private Map<String, String> options = new HashMap<>();
042        private Map<String, String> tokenOptions = new HashMap<>();
043
044        /* (non-Javadoc)
045         * @see org.mitre.openid.connect.client.service.AuthRequestOptionsService#getOptions(org.mitre.openid.connect.config.ServerConfiguration, org.mitre.oauth2.model.RegisteredClient, javax.servlet.http.HttpServletRequest)
046         */
047        @Override
048        public Map<String, String> getOptions(ServerConfiguration server, RegisteredClient client, HttpServletRequest request) {
049                return options;
050        }
051
052        /* (non-Javadoc)
053         * @see org.mitre.openid.connect.client.service.AuthRequestOptionsService#getTokenOptions(org.mitre.openid.connect.config.ServerConfiguration, org.mitre.oauth2.model.RegisteredClient, javax.servlet.http.HttpServletRequest)
054         */
055        @Override
056        public Map<String, String> getTokenOptions(ServerConfiguration server, RegisteredClient client, HttpServletRequest request) {
057                return tokenOptions;
058        }
059
060        /**
061         * @return the options object directly
062         */
063        public Map<String, String> getOptions() {
064                return options;
065        }
066
067        /**
068         * @param options the options to set
069         */
070        public void setOptions(Map<String, String> options) {
071                this.options = options;
072        }
073
074        /**
075         * @return the tokenOptions
076         */
077        public Map<String, String> getTokenOptions() {
078                return tokenOptions;
079        }
080
081        /**
082         * @param tokenOptions the tokenOptions to set
083         */
084        public void setTokenOptions(Map<String, String> tokenOptions) {
085                this.tokenOptions = tokenOptions;
086        }
087
088}