This commit is contained in:
Janne Valkealahti
2023-05-23 08:28:36 +01:00
parent aff389f2fa
commit a3098e265a
5 changed files with 10 additions and 88 deletions

View File

@@ -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<String, Object> loginOptions, HttpClient httpClient) {
this(keyTabLocation, userPrincipal, null, loginOptions, httpClient);
}
/**
* Instantiates a new kerberos rest template.
*

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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;
/**