Skip to content

Commit 997a7c4

Browse files
author
François
committed
Issues/300: Replace Lombok annotation & add log
1 parent 57d1937 commit 997a7c4

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

api/src/main/java/io/kafbat/ui/model/rbac/Subject.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@
55

66
import io.kafbat.ui.model.rbac.provider.Provider;
77
import java.util.Objects;
8-
import lombok.Getter;
9-
import lombok.Setter;
8+
import lombok.Data;
109

11-
@Getter
10+
@Data
1211
public class Subject {
1312

1413
Provider provider;
15-
@Setter
1614
String type;
17-
@Setter
1815
String value;
19-
@Setter
20-
boolean isRegex;
21-
22-
public void setProvider(String provider) {
23-
this.provider = Provider.fromString(provider.toUpperCase());
24-
}
16+
boolean isRegex = false;
2517

2618
public void validate() {
2719
checkNotNull(type, "Subject type cannot be null");
@@ -32,9 +24,9 @@ public void validate() {
3224
}
3325

3426
public boolean matches(final String attribute) {
35-
if (isRegex()) {
36-
return Objects.nonNull(attribute) && attribute.matches(getValue());
27+
if (isRegex) {
28+
return Objects.nonNull(attribute) && attribute.matches(this.value);
3729
}
38-
return getValue().equalsIgnoreCase(attribute);
30+
return this.value.equalsIgnoreCase(attribute);
3931
}
4032
}

api/src/main/java/io/kafbat/ui/service/rbac/extractor/OauthAuthorityExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ private Set<String> extractUsernameRoles(AccessControlService acs, DefaultOAuth2
5858
.stream()
5959
.filter(s -> s.getProvider().equals(Provider.OAUTH))
6060
.filter(s -> s.getType().equals("user"))
61+
.peek(s -> log.trace("[{}] matches [{}]? [{}]", s.getValue(), principalName, s.matches(principalName)))
6162
.anyMatch(s -> s.matches(principalName)))
6263
.map(Role::getName)
6364
.collect(Collectors.toSet());

0 commit comments

Comments
 (0)