diff --git a/spring-security-kerberos-client/src/main/java/org/springframework/security/kerberos/client/KerberosRestTemplate.java b/spring-security-kerberos-client/src/main/java/org/springframework/security/kerberos/client/KerberosRestTemplate.java index 3effafb..8aa2b31 100644 --- a/spring-security-kerberos-client/src/main/java/org/springframework/security/kerberos/client/KerberosRestTemplate.java +++ b/spring-security-kerberos-client/src/main/java/org/springframework/security/kerberos/client/KerberosRestTemplate.java @@ -163,18 +163,6 @@ public class KerberosRestTemplate extends RestTemplate { this(keyTabLocation, userPrincipal, password, loginOptions, buildHttpClient()); } - /** - * Instantiates a new kerberos rest template. - * - * @param keyTabLocation the key tab location - * @param userPrincipal the user principal - * @param loginOptions the login options - * @param httpClient the http client - */ - private KerberosRestTemplate(String keyTabLocation, String userPrincipal, Map loginOptions, HttpClient httpClient) { - this(keyTabLocation, userPrincipal, null, loginOptions, httpClient); - } - /** * Instantiates a new kerberos rest template. * diff --git a/spring-security-kerberos-core/src/test/java/org/springframework/security/kerberos/authentication/KerberosServiceAuthenticationProviderTest.java b/spring-security-kerberos-core/src/test/java/org/springframework/security/kerberos/authentication/KerberosServiceAuthenticationProviderTest.java index be43233..6842eb6 100644 --- a/spring-security-kerberos-core/src/test/java/org/springframework/security/kerberos/authentication/KerberosServiceAuthenticationProviderTest.java +++ b/spring-security-kerberos-core/src/test/java/org/springframework/security/kerberos/authentication/KerberosServiceAuthenticationProviderTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2015 the original author or authors. + * Copyright 2009-2023 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. @@ -34,10 +34,6 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.kerberos.authentication.KerberosServiceAuthenticationProvider; -import org.springframework.security.kerberos.authentication.KerberosServiceRequestToken; -import org.springframework.security.kerberos.authentication.KerberosTicketValidation; -import org.springframework.security.kerberos.authentication.KerberosTicketValidator; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/AuthProviderConfig.java b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/AuthProviderConfig.java index 1b55b36..19847c3 100644 --- a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/AuthProviderConfig.java +++ b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/AuthProviderConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2023 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. @@ -17,37 +17,12 @@ package org.springframework.security.kerberos.docs; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -// import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -// import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; import org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider; import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosClient; //tag::snippetA[] @Configuration -// @EnableWebMvcSecurity -public class AuthProviderConfig /*extends WebSecurityConfigurerAdapter*/ { - - // @Override - // protected void configure(HttpSecurity http) throws Exception { - // http - // .authorizeRequests() - // .antMatchers("/", "/home").permitAll() - // .anyRequest().authenticated() - // .and() - // .formLogin() - // .loginPage("/login").permitAll() - // .and() - // .logout() - // .permitAll(); - // } - - // @Override - // protected void configure(AuthenticationManagerBuilder auth) throws Exception { - // auth - // .authenticationProvider(kerberosAuthenticationProvider()); - // } +public class AuthProviderConfig { @Bean public KerberosAuthenticationProvider kerberosAuthenticationProvider() { diff --git a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/SpnegoConfig.java b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/SpnegoConfig.java index 518e48f..ae264ed 100644 --- a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/SpnegoConfig.java +++ b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/docs/SpnegoConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 the original author or authors. + * Copyright 2015-2023 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. @@ -19,51 +19,16 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.FileSystemResource; import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -// import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -// import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; import org.springframework.security.kerberos.authentication.KerberosAuthenticationProvider; import org.springframework.security.kerberos.authentication.KerberosServiceAuthenticationProvider; import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosClient; import org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator; import org.springframework.security.kerberos.web.authentication.SpnegoAuthenticationProcessingFilter; import org.springframework.security.kerberos.web.authentication.SpnegoEntryPoint; -import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; //tag::snippetA[] @Configuration -// @EnableWebMvcSecurity -public class SpnegoConfig /*extends WebSecurityConfigurerAdapter*/ { - - // @Override - // protected void configure(HttpSecurity http) throws Exception { - // http - // .exceptionHandling() - // .authenticationEntryPoint(spnegoEntryPoint()) - // .and() - // .authorizeRequests() - // .antMatchers("/", "/home").permitAll() - // .anyRequest().authenticated() - // .and() - // .formLogin() - // .loginPage("/login").permitAll() - // .and() - // .logout() - // .permitAll() - // .and() - // .addFilterBefore( - // spnegoAuthenticationProcessingFilter(authenticationManagerBean()), - // BasicAuthenticationFilter.class); - // } - - // @Override - // protected void configure(AuthenticationManagerBuilder auth) - // throws Exception { - // auth - // .authenticationProvider(kerberosAuthenticationProvider()) - // .authenticationProvider(kerberosServiceAuthenticationProvider()); - // } +public class SpnegoConfig { @Bean public KerberosAuthenticationProvider kerberosAuthenticationProvider() { diff --git a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/web/SpnegoAuthenticationProcessingFilterTest.java b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/web/SpnegoAuthenticationProcessingFilterTest.java index 0710103..3088b73 100644 --- a/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/web/SpnegoAuthenticationProcessingFilterTest.java +++ b/spring-security-kerberos-web/src/test/java/org/springframework/security/kerberos/web/SpnegoAuthenticationProcessingFilterTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2009-2015 the original author or authors. + * Copyright 2009-2023 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. @@ -15,11 +15,6 @@ */ package org.springframework.security.kerberos.web; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.io.IOException; import jakarta.servlet.FilterChain; @@ -31,7 +26,6 @@ import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatchers; import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.authentication.AuthenticationManager; @@ -51,6 +45,10 @@ import org.springframework.security.web.authentication.WebAuthenticationDetailsS import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /**