瀏覽代碼

Add ClientAuthenticationMethod constants tls_client_auth and self_signed_tls_client_auth

Closes gh-14889
Joe Grandja 1 年之前
父節點
當前提交
9a7f1aa4d9

+ 12 - 1
oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/ClientAuthenticationMethod.java

@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2022 the original author or authors.
+ * Copyright 2002-2024 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -62,6 +62,17 @@ public final class ClientAuthenticationMethod implements Serializable {
 	 */
 	public static final ClientAuthenticationMethod NONE = new ClientAuthenticationMethod("none");
 
+	/**
+	 * @since 6.3
+	 */
+	public static final ClientAuthenticationMethod TLS_CLIENT_AUTH = new ClientAuthenticationMethod("tls_client_auth");
+
+	/**
+	 * @since 6.3
+	 */
+	public static final ClientAuthenticationMethod SELF_SIGNED_TLS_CLIENT_AUTH = new ClientAuthenticationMethod(
+			"self_signed_tls_client_auth");
+
 	private final String value;
 
 	/**

+ 12 - 1
oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/ClientAuthenticationMethodTests.java

@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2022 the original author or authors.
+ * Copyright 2002-2024 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,4 +58,15 @@ public class ClientAuthenticationMethodTests {
 		assertThat(ClientAuthenticationMethod.NONE.getValue()).isEqualTo("none");
 	}
 
+	@Test
+	public void getValueWhenAuthenticationMethodTlsClientAuthThenReturnTlsClientAuth() {
+		assertThat(ClientAuthenticationMethod.TLS_CLIENT_AUTH.getValue()).isEqualTo("tls_client_auth");
+	}
+
+	@Test
+	public void getValueWhenAuthenticationMethodSelfSignedTlsClientAuthThenReturnSelfSignedTlsClientAuth() {
+		assertThat(ClientAuthenticationMethod.SELF_SIGNED_TLS_CLIENT_AUTH.getValue())
+			.isEqualTo("self_signed_tls_client_auth");
+	}
+
 }