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 static net.openid.appauth.Preconditions.checkNotNull; 018 019import androidx.annotation.NonNull; 020 021import java.util.HashMap; 022import java.util.Map; 023 024 025/** 026 * Implementation of the client authentication method 'client_secret_post'. 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 ClientSecretPost implements ClientAuthentication { 032 /** 033 * Name of this authentication method. 034 * 035 * @see "OpenID Connect Core 1.0, Section 9 036 * <https://openid.net/specs/openid-connect-core-1_0.html#rfc.section.9>" 037 */ 038 public static final String NAME = "client_secret_post"; 039 static final String PARAM_CLIENT_ID = "client_id"; 040 static final String PARAM_CLIENT_SECRET = "client_secret"; 041 042 @NonNull 043 private String mClientSecret; 044 045 /** 046 * Creates a {@link ClientAuthentication} which will use the client authentication method 047 * `client_secret_post`. 048 */ 049 public ClientSecretPost(@NonNull String clientSecret) { 050 mClientSecret = checkNotNull(clientSecret, "clientSecret cannot be null"); 051 } 052 053 @Override 054 public final Map<String, String> getRequestParameters(@NonNull String clientId) { 055 Map<String, String> additionalParameters = new HashMap<>(); 056 additionalParameters.put(PARAM_CLIENT_ID, clientId); 057 additionalParameters.put(PARAM_CLIENT_SECRET, mClientSecret); 058 return additionalParameters; 059 } 060 061 @Override 062 public final Map<String, String> getRequestHeaders(@NonNull String clientId) { 063 return null; 064 } 065}