224 if (client.getGrantTypes().contains(
"authorization_code")) {
226 if (client.getGrantTypes().contains(
"implicit") || client.getGrantTypes().contains(
"client_credentials")) {
227 throw new IllegalArgumentException(
"[HEART mode] Incompatible grant types");
231 if (client.getTokenEndpointAuthMethod() == null || !client.getTokenEndpointAuthMethod().equals(AuthMethod.PRIVATE_KEY)) {
232 throw new IllegalArgumentException(
"[HEART mode] Authorization code clients must use the private_key authentication method");
236 if (client.getRedirectUris().isEmpty()) {
237 throw new IllegalArgumentException(
"[HEART mode] Authorization code clients must register at least one redirect URI");
241 if (client.getGrantTypes().contains(
"implicit")) {
243 if (client.getGrantTypes().contains(
"authorization_code") || client.getGrantTypes().contains(
"client_credentials") || client.getGrantTypes().contains(
"refresh_token")) {
244 throw new IllegalArgumentException(
"[HEART mode] Incompatible grant types");
248 if (client.getTokenEndpointAuthMethod() == null || !client.getTokenEndpointAuthMethod().equals(AuthMethod.NONE)) {
249 throw new IllegalArgumentException(
"[HEART mode] Implicit clients must use the none authentication method");
253 if (client.getRedirectUris().isEmpty()) {
254 throw new IllegalArgumentException(
"[HEART mode] Implicit clients must register at least one redirect URI");
258 if (client.getGrantTypes().contains(
"client_credentials")) {
260 if (client.getGrantTypes().contains(
"authorization_code") || client.getGrantTypes().contains(
"implicit") || client.getGrantTypes().contains(
"refresh_token")) {
261 throw new IllegalArgumentException(
"[HEART mode] Incompatible grant types");
265 if (client.getTokenEndpointAuthMethod() == null || !client.getTokenEndpointAuthMethod().equals(AuthMethod.PRIVATE_KEY)) {
266 throw new IllegalArgumentException(
"[HEART mode] Client credentials clients must use the private_key authentication method");
270 if (!client.getRedirectUris().isEmpty()) {
271 throw new IllegalArgumentException(
"[HEART mode] Client credentials clients must not register a redirect URI");
276 if (client.getGrantTypes().contains(
"password")) {
277 throw new IllegalArgumentException(
"[HEART mode] Password grant type is forbidden");
281 if (!Strings.isNullOrEmpty(client.getClientSecret())) {
282 throw new IllegalArgumentException(
"[HEART mode] Client secrets are not allowed");
286 if (client.getJwks() == null && Strings.isNullOrEmpty(client.getJwksUri())) {
287 throw new IllegalArgumentException(
"[HEART mode] All clients must have a key registered");
291 if (client.getRedirectUris() != null && !client.getRedirectUris().isEmpty()) {
292 boolean localhost =
false;
293 boolean remoteHttps =
false;
294 boolean customScheme =
false;
295 for (String uri : client.getRedirectUris()) {
296 UriComponents components = UriComponentsBuilder.fromUriString(uri).build();
297 if (components.getScheme() == null) {
300 }
else if (components.getScheme().equals(
"http")) {
302 if (components.getHost().equals(
"localhost") || components.getHost().equals(
"127.0.0.1")) {
305 throw new IllegalArgumentException(
"[HEART mode] Can't have an http redirect URI on non-local host");
307 }
else if (components.getScheme().equals(
"https")) {
315 if (!((localhost ^ remoteHttps ^ customScheme)
316 && !(localhost && remoteHttps && customScheme))) {
317 throw new IllegalArgumentException(
"[HEART mode] Can't have more than one class of redirect URI");
ConfigurationPropertiesBean config
Definition: DefaultOAuth2ClientDetailsEntityService.java:101
boolean isHeartMode()
Definition: ConfigurationPropertiesBean.java:250