add null checks

This commit is contained in:
kritzl 2026-03-31 14:31:07 +02:00
commit 5e791af057
Signed by: kritzl
SSH key fingerprint: SHA256:5BmINP9VjZWaUk5Z+2CTut1KFhwLtd0ZynMekKbtViM

View file

@ -54,6 +54,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
String configAttributeSlug = model.getConfig().getFirst("slug");
if (configAttributeSlug == null) {
hasError = true;
errorString += " • [Slug] can not be empty\n";
}
if (!slugPattern.matcher(configAttributeSlug).matches()) {
hasError = true;
@ -61,6 +65,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
}
String configAuthRole = model.getConfig().getFirst("auth-role");
if (configAuthRole == null) {
hasError = true;
errorString += " • [Auth Role] can not be empty\n";
}
RoleModel authRole = realm.getRole(configAuthRole);
if (authRole == null) {
hasError = true;
@ -68,6 +77,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
}
String configMatchRole = model.getConfig().getFirst("match-role");
if (configMatchRole == null) {
hasError = true;
errorString += " • [Match Role] can not be empty\n";
}
RoleModel matchRole = realm.getRole(configMatchRole);
if (matchRole == null) {
hasError = true;
@ -77,6 +91,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
UserProfileProvider profileProvider = session.getProvider(UserProfileProvider.class);
UPConfig upconfig = profileProvider.getConfiguration();
String configAttributeGroup = model.getConfig().getFirst("attribute-group");
if (configAttributeGroup == null) {
hasError = true;
errorString += " • [Attribute Group] can not be empty\n";
}
if (!upconfig.getGroups().stream().anyMatch(g -> g.getName().equals(configAttributeGroup))) {
hasError = true;
errorString += " • [Attribute Group] does not exist\n";