Skip to content

Commit b6ef8de

Browse files
BAEL-124 - Minor refactors
1 parent 679dfa1 commit b6ef8de

11 files changed

Lines changed: 1 addition & 180 deletions

File tree

‎spring-security-x509/basic-secured-server/src/main/java/com/baeldung/spring/security/x509/X509AuthenticationServer.java‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,8 @@
1515

1616
@SpringBootApplication
1717
@EnableWebSecurity
18-
@EnableGlobalMethodSecurity(prePostEnabled = true)
1918
public class X509AuthenticationServer extends WebSecurityConfigurerAdapter {
2019
public static void main(String[] args) {
2120
SpringApplication.run(X509AuthenticationServer.class, args);
2221
}
23-
24-
@Override
25-
protected void configure(HttpSecurity http) throws Exception {
26-
http.authorizeRequests().anyRequest().authenticated()
27-
.and()
28-
.x509().subjectPrincipalRegex("CN=(.*?)(?:,|$)").userDetailsService(userDetailsService());
29-
}
30-
31-
@Bean
32-
public UserDetailsService userDetailsService() {
33-
return new UserDetailsService() {
34-
@Override
35-
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
36-
if (username.equals("cid")) {
37-
return new User(username, "", AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
38-
}
39-
throw new UsernameNotFoundException("User not found!");
40-
}
41-
};
42-
}
4322
}

‎spring-security-x509/basic-secured-server/src/main/resources/application.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
server.ssl.key-store=classpath:keystore.jks
1+
server.ssl.key-store=../keystore/keystore.jks
22
server.ssl.key-store-password=changeit
33
server.ssl.key-alias=localhost
44
server.ssl.key-password=changeit
Binary file not shown.

‎spring-security-x509/keystore/ca.crt‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎spring-security-x509/keystore/cid.crt‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎spring-security-x509/keystore/cid.csr‎

Lines changed: 0 additions & 25 deletions
This file was deleted.
-5.78 KB
Binary file not shown.

‎spring-security-x509/keystore/create-keystore.bat‎

Lines changed: 0 additions & 24 deletions
This file was deleted.

‎spring-security-x509/keystore/localhost.crt‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎spring-security-x509/keystore/localhost.csr‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)