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.keypublisher; 022 023import java.lang.reflect.Method; 024 025import org.springframework.stereotype.Component; 026import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; 027import org.springframework.web.servlet.mvc.method.RequestMappingInfo; 028import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; 029 030/** 031 * @author jricher 032 * 033 */ 034@Component 035public class ClientKeyPublisherMapping extends RequestMappingInfoHandlerMapping { 036 037 private String jwkPublishUrl; 038 039 /* (non-Javadoc) 040 * @see org.springframework.web.servlet.handler.AbstractHandlerMethodMapping#isHandler(java.lang.Class) 041 */ 042 @Override 043 protected boolean isHandler(Class<?> beanType) { 044 return beanType.equals(ClientKeyPublisher.class); 045 } 046 047 /** 048 * Map the "jwkKeyPublish" method to our jwkPublishUrl. 049 */ 050 @Override 051 protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType) { 052 053 if (method.getName().equals("publishClientJwk") && getJwkPublishUrl() != null) { 054 return new RequestMappingInfo( 055 new PatternsRequestCondition(new String[] {getJwkPublishUrl()}, getUrlPathHelper(), getPathMatcher(), false, false), 056 null, 057 null, 058 null, 059 null, 060 null, 061 null); 062 } else { 063 return null; 064 } 065 066 } 067 068 /** 069 * @return the jwkPublishUrl 070 */ 071 public String getJwkPublishUrl() { 072 return jwkPublishUrl; 073 } 074 075 /** 076 * @param jwkPublishUrl the jwkPublishUrl to set 077 */ 078 public void setJwkPublishUrl(String jwkPublishUrl) { 079 this.jwkPublishUrl = jwkPublishUrl; 080 } 081 082}