Skip to content

Commit e35faa8

Browse files
Create NoOpAuthenticationEntryPoint
Closes gh-13107
1 parent 7e0fcb7 commit e35faa8

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2002-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.web.authentication;
18+
19+
import java.io.IOException;
20+
21+
import jakarta.servlet.ServletException;
22+
import jakarta.servlet.http.HttpServletRequest;
23+
import jakarta.servlet.http.HttpServletResponse;
24+
25+
import org.springframework.security.core.AuthenticationException;
26+
import org.springframework.security.web.AuthenticationEntryPoint;
27+
28+
/**
29+
* An {@link AuthenticationEntryPoint} implementation that does nothing.
30+
*
31+
* @author Marcus da Coregio
32+
* @since 6.2
33+
*/
34+
public class NoOpAuthenticationEntryPoint implements AuthenticationEntryPoint {
35+
36+
@Override
37+
public void commence(HttpServletRequest request, HttpServletResponse response,
38+
AuthenticationException authException) throws IOException, ServletException {
39+
40+
}
41+
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2002-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.web.authentication;
18+
19+
import jakarta.servlet.http.HttpServletRequest;
20+
import jakarta.servlet.http.HttpServletResponse;
21+
import org.junit.jupiter.api.Test;
22+
23+
import org.springframework.security.core.AuthenticationException;
24+
25+
import static org.mockito.Mockito.mock;
26+
import static org.mockito.Mockito.verifyNoInteractions;
27+
28+
class NoOpAuthenticationEntryPointTests {
29+
30+
private final NoOpAuthenticationEntryPoint authenticationEntryPoint = new NoOpAuthenticationEntryPoint();
31+
32+
@Test
33+
void commenceWhenInvokedThenDoesNothing() throws Exception {
34+
HttpServletRequest request = mock(HttpServletRequest.class);
35+
HttpServletResponse response = mock(HttpServletResponse.class);
36+
AuthenticationException exception = mock(AuthenticationException.class);
37+
this.authenticationEntryPoint.commence(request, response, exception);
38+
verifyNoInteractions(request, response, exception);
39+
}
40+
41+
}

0 commit comments

Comments
 (0)