001/******************************************************************************* 002 * Copyright 2017 The MIT Internet Trust Consortium 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 *******************************************************************************/ 016 017package org.mitre.uma.web; 018 019import java.util.ArrayList; 020import java.util.HashMap; 021import java.util.Map; 022 023import org.mitre.oauth2.web.IntrospectionEndpoint; 024import org.mitre.openid.connect.config.ConfigurationPropertiesBean; 025import org.mitre.openid.connect.view.JsonEntityView; 026import org.mitre.openid.connect.web.DynamicClientRegistrationEndpoint; 027import org.springframework.beans.factory.annotation.Autowired; 028import org.springframework.stereotype.Controller; 029import org.springframework.ui.Model; 030import org.springframework.web.bind.annotation.RequestMapping; 031 032import com.google.common.collect.ImmutableSet; 033import com.google.common.collect.Lists; 034 035/** 036 * @author jricher 037 * 038 */ 039@Controller 040public class UmaDiscoveryEndpoint { 041 042 @Autowired 043 private ConfigurationPropertiesBean config; 044 045 @RequestMapping(".well-known/uma-configuration") 046 public String umaConfiguration(Model model) { 047 048 Map<String, Object> m = new HashMap<>(); 049 050 String issuer = config.getIssuer(); 051 ImmutableSet<String> tokenProfiles = ImmutableSet.of("bearer"); 052 ArrayList<String> grantTypes = Lists.newArrayList("authorization_code", "implicit", "urn:ietf:params:oauth:grant-type:jwt-bearer", "client_credentials", "urn:ietf:params:oauth:grant_type:redelegate"); 053 054 m.put("version", "1.0"); 055 m.put("issuer", issuer); 056 m.put("pat_profiles_supported", tokenProfiles); 057 m.put("aat_profiles_supported", tokenProfiles); 058 m.put("rpt_profiles_supported", tokenProfiles); 059 m.put("pat_grant_types_supported", grantTypes); 060 m.put("aat_grant_types_supported", grantTypes); 061 m.put("claim_token_profiles_supported", ImmutableSet.of()); 062 m.put("uma_profiles_supported", ImmutableSet.of()); 063 m.put("dynamic_client_endpoint", issuer + DynamicClientRegistrationEndpoint.URL); 064 m.put("token_endpoint", issuer + "token"); 065 m.put("authorization_endpoint", issuer + "authorize"); 066 m.put("requesting_party_claims_endpoint", issuer + ClaimsCollectionEndpoint.URL); 067 m.put("introspection_endpoint", issuer + IntrospectionEndpoint.URL); 068 m.put("resource_set_registration_endpoint", issuer + ResourceSetRegistrationEndpoint.DISCOVERY_URL); 069 m.put("permission_registration_endpoint", issuer + PermissionRegistrationEndpoint.URL); 070 m.put("rpt_endpoint", issuer + AuthorizationRequestEndpoint.URL); 071 072 073 074 model.addAttribute("entity", m); 075 return JsonEntityView.VIEWNAME; 076 } 077 078 079}