001/******************************************************************************* 002 * Copyright 2018 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.oauth2.introspectingfilter.service.impl; 022 023import java.util.List; 024 025import org.mitre.oauth2.introspectingfilter.service.IntrospectionAuthorityGranter; 026import org.springframework.security.core.GrantedAuthority; 027import org.springframework.security.core.authority.AuthorityUtils; 028 029import com.google.gson.JsonObject; 030 031/** 032 * 033 * Grants the same set of authorities no matter what's passed in. 034 * 035 * @author jricher 036 * 037 */ 038public class SimpleIntrospectionAuthorityGranter implements IntrospectionAuthorityGranter { 039 040 private List<GrantedAuthority> authorities = AuthorityUtils.createAuthorityList("ROLE_API"); 041 042 /* (non-Javadoc) 043 * @see org.mitre.oauth2.introspectingfilter.IntrospectionAuthorityGranter#getAuthorities(net.minidev.json.JSONObject) 044 */ 045 @Override 046 public List<GrantedAuthority> getAuthorities(JsonObject introspectionResponse) { 047 return authorities; 048 } 049 050 /** 051 * @return the authorities 052 */ 053 public List<GrantedAuthority> getAuthorities() { 054 return authorities; 055 } 056 057 /** 058 * @param authorities the authorities to set 059 */ 060 public void setAuthorities(List<GrantedAuthority> authorities) { 061 this.authorities = authorities; 062 } 063 064}