本文整理匯總了Java中org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails.getClientSecret方法的典型用法代碼示例。如果您正苦於以下問題:Java OAuth2ProtectedResourceDetails.getClientSecret方法的具體用法?Java OAuth2ProtectedResourceDetails.getClientSecret怎麽用?Java OAuth2ProtectedResourceDetails.getClientSecret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails
的用法示例。
在下文中一共展示了OAuth2ProtectedResourceDetails.getClientSecret方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: authenticateTokenRequest
import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails; //導入方法依賴的package包/類
public void authenticateTokenRequest(OAuth2ProtectedResourceDetails resource, MultiValueMap<String, String> form,
HttpHeaders headers) {
if (resource.isAuthenticationRequired()) {
AuthenticationScheme scheme = AuthenticationScheme.header;
if (resource.getClientAuthenticationScheme() != null) {
scheme = resource.getClientAuthenticationScheme();
}
try {
String clientSecret = resource.getClientSecret();
clientSecret = clientSecret == null ? "" : clientSecret;
switch (scheme) {
case header:
form.remove("client_secret");
headers.add(
"Authorization",
String.format(
"Basic %s",
new String(Base64.encode(String.format("%s:%s", resource.getClientId(),
clientSecret).getBytes("UTF-8")), "UTF-8")));
break;
case form:
case query:
form.set("client_id", resource.getClientId());
if (StringUtils.hasText(clientSecret)) {
form.set("client_secret", clientSecret);
}
break;
default:
throw new IllegalStateException(
"Default authentication handler doesn't know how to handle scheme: " + scheme);
}
}
catch (UnsupportedEncodingException e) {
throw new IllegalStateException(e);
}
}
}