Skip to content

Commit dc63a31

Browse files
authored
Merge pull request #58 from redlink-gmbh/umm/401-resolve-incompatibilitis-with-studymanager-services-module
MORE-Platform#401: Refactoring and Removal of not strictly needed classes
2 parents cbcc2e1 + 1bbc33c commit dc63a31

34 files changed

Lines changed: 51 additions & 424 deletions

studymanager-auth-token/src/main/java/io/redlink/more/auth/event/ParticipantUpdateAction.java

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

studymanager-auth-token/src/main/java/io/redlink/more/auth/event/ParticipantUpdateEvent.java

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

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/configuration/AuthenticationFacade.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
package io.redlink.more.auth.token.configuration;
1010

11-
import io.redlink.more.auth.token.model.LoginTokenUserDetails;
11+
import io.redlink.more.auth.token.model.TokenAuthUserDetails;
1212
import org.springframework.security.access.AccessDeniedException;
1313
import org.springframework.security.core.Authentication;
1414
import org.springframework.security.core.GrantedAuthority;
@@ -29,11 +29,11 @@ public Authentication getAuthentication() {
2929
/**
3030
* Asserts that hte current authentication context contains the provided authority ("role").
3131
* @param authority the required authority
32-
* @return the authentication principal as {@link LoginTokenUserDetails}.
32+
* @return the authentication principal as {@link TokenAuthUserDetails}.
3333
* @throws IllegalArgumentException if authority is {@code null}
3434
* @throws AccessDeniedException if not authentication context is available or the required authority is not present.
3535
*/
36-
public LoginTokenUserDetails assertAuthority(String authority) {
36+
public TokenAuthUserDetails assertAuthority(String authority) {
3737
if (authority == null) throw new IllegalArgumentException("authority must not be null");
3838

3939
final Authentication authentication = getAuthentication();
@@ -45,7 +45,7 @@ public LoginTokenUserDetails assertAuthority(String authority) {
4545
.map(GrantedAuthority::getAuthority)
4646
.anyMatch(authority::equals)) {
4747
final Object principal = authentication.getPrincipal();
48-
if (principal instanceof LoginTokenUserDetails userDetails) {
48+
if (principal instanceof TokenAuthUserDetails userDetails) {
4949
return userDetails;
5050
}
5151
}

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/configuration/DaoAuthenticationConfiguration.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.redlink.more.auth.token.configuration;
22

3-
import io.redlink.more.auth.token.service.LoginTokenUserDetailService;
3+
import io.redlink.more.auth.token.service.TokenAuthUserDetailService;
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
@@ -17,17 +17,17 @@
1717
@Configuration
1818
public class DaoAuthenticationConfiguration {
1919

20-
private final LoginTokenUserDetailService loginTokenUserDetailService;
20+
private final TokenAuthUserDetailService tokenAuthUserDetailService;
2121

22-
DaoAuthenticationConfiguration(LoginTokenUserDetailService loginTokenUserDetailService) {
23-
this.loginTokenUserDetailService = loginTokenUserDetailService;
22+
DaoAuthenticationConfiguration(TokenAuthUserDetailService tokenAuthUserDetailService) {
23+
this.tokenAuthUserDetailService = tokenAuthUserDetailService;
2424
}
2525

2626
@Bean
2727
public DaoAuthenticationProvider authenticationProvider(PasswordEncoder passwordEncoder) {
2828
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
2929
provider.setPasswordEncoder(passwordEncoder);
30-
provider.setUserDetailsService(loginTokenUserDetailService);
30+
provider.setUserDetailsService(tokenAuthUserDetailService);
3131
return provider;
3232
}
3333

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/configuration/LoginTokenProperties.java

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

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/model/LoginToken.java

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

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/model/LoginTokenUserDetails.java renamed to studymanager-auth-token/src/main/java/io/redlink/more/auth/token/model/TokenAuthUserDetails.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import java.util.Set;
1717
import java.util.stream.Collectors;
1818

19-
public class LoginTokenUserDetails extends User {
19+
public class TokenAuthUserDetails extends User {
2020

2121
private final RoutingInfo routingInfo;
2222

23-
public LoginTokenUserDetails(String username, String password, Set<String> roles, RoutingInfo routingInfo) {
23+
public TokenAuthUserDetails(String username, String password, Set<String> roles, RoutingInfo routingInfo) {
2424
super(username, password, roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toSet()));
2525
this.routingInfo = routingInfo;
2626
}
@@ -34,7 +34,7 @@ public boolean equals(Object o) {
3434
if (this == o) return true;
3535
if (o == null || getClass() != o.getClass()) return false;
3636
if (!super.equals(o)) return false;
37-
LoginTokenUserDetails that = (LoginTokenUserDetails) o;
37+
TokenAuthUserDetails that = (TokenAuthUserDetails) o;
3838
return Objects.equals(routingInfo, that.routingInfo);
3939
}
4040

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/repository/LoginTokenRepository.java

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

studymanager-auth-token/src/main/java/io/redlink/more/auth/token/repository/LoginTokenUserRepository.java renamed to studymanager-auth-token/src/main/java/io/redlink/more/auth/token/repository/TokenAuthUserRepository.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
package io.redlink.more.auth.token.repository;
1010

11-
import io.redlink.more.auth.token.model.LoginTokenUserDetails;
11+
import io.redlink.more.auth.token.model.TokenAuthUserDetails;
1212
import io.redlink.more.auth.model.RoutingInfo;
1313
import org.springframework.jdbc.core.JdbcTemplate;
1414
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -21,18 +21,18 @@
2121
import java.util.Set;
2222

2323
@Service
24-
public class LoginTokenUserRepository {
24+
public class TokenAuthUserRepository {
2525

2626
private static final String GET_AUTH_ROUTING_INFO =
2727
"SELECT * FROM auth_routing_info WHERE api_id = :api_id";
2828

2929
private final NamedParameterJdbcTemplate jdbcTemplate;
3030

31-
public LoginTokenUserRepository(JdbcTemplate jdbcTemplate) {
31+
public TokenAuthUserRepository(JdbcTemplate jdbcTemplate) {
3232
this.jdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
3333
}
3434

35-
public Optional<LoginTokenUserDetails> findByApiId(String apiId, Set<String> roles) {
35+
public Optional<TokenAuthUserDetails> findByApiId(String apiId, Set<String> roles) {
3636
try (var stream = jdbcTemplate.queryForStream(
3737
GET_AUTH_ROUTING_INFO,
3838
Map.of("api_id", apiId),
@@ -42,8 +42,8 @@ public Optional<LoginTokenUserDetails> findByApiId(String apiId, Set<String> rol
4242
}
4343
}
4444

45-
private static LoginTokenUserDetails readUserDetails(ResultSet rs, Set<String> roles) throws SQLException {
46-
return new LoginTokenUserDetails(
45+
private static TokenAuthUserDetails readUserDetails(ResultSet rs, Set<String> roles) throws SQLException {
46+
return new TokenAuthUserDetails(
4747
rs.getString("api_id"),
4848
rs.getString("api_secret"),
4949
roles,

0 commit comments

Comments
 (0)