001/* 002 * Copyright 2016 The AppAuth for Android Authors. All Rights Reserved. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the 010 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 011 * express or implied. See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 015package net.openid.appauth; 016 017import androidx.annotation.NonNull; 018 019import java.util.Collections; 020import java.util.Map; 021 022/** 023 * Implementation of the client authentication method 'none'. This is the default, 024 * if no other authentication method is specified when calling 025 * {@link AuthorizationService#performTokenRequest(TokenRequest, 026 * AuthorizationService.TokenResponseCallback)}. 027 * 028 * @see "OpenID Connect Core 1.0, Section 9 029 * <https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.9>" 030 */ 031public class NoClientAuthentication implements ClientAuthentication { 032 /** 033 * Name of this authentication method. 034 */ 035 public static final String NAME = "none"; 036 037 /** 038 * The default (singleton) instance of {@link NoClientAuthentication}. 039 */ 040 public static final NoClientAuthentication INSTANCE = new NoClientAuthentication(); 041 042 private NoClientAuthentication() { 043 // no need to instantiate separate instances from INSTANCE 044 } 045 046 /** 047 * {@inheritDoc} 048 * 049 * @return always `null`. 050 */ 051 @Override 052 public Map<String, String> getRequestHeaders(@NonNull String clientId) { 053 return null; 054 } 055 056 /** 057 * {@inheritDoc} 058 * 059 * Where no alternative form of client authentication is used, the client_id is simply 060 * sent as a client identity assertion. 061 */ 062 @Override 063 public Map<String, String> getRequestParameters(@NonNull String clientId) { 064 return Collections.singletonMap(TokenRequest.PARAM_CLIENT_ID, clientId); 065 } 066}