Configure Extension with UiPageProvider #1
1 changed files with 18 additions and 0 deletions
add null checks
commit
5e791af057
|
|
@ -54,6 +54,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
|
|
||||||
Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
|
Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");
|
||||||
String configAttributeSlug = model.getConfig().getFirst("slug");
|
String configAttributeSlug = model.getConfig().getFirst("slug");
|
||||||
|
if (configAttributeSlug == null) {
|
||||||
|
hasError = true;
|
||||||
|
|
|||||||
|
errorString += " • [Slug] can not be empty\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!slugPattern.matcher(configAttributeSlug).matches()) {
|
if (!slugPattern.matcher(configAttributeSlug).matches()) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -61,6 +65,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
}
|
}
|
||||||
|
|
||||||
String configAuthRole = model.getConfig().getFirst("auth-role");
|
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);
|
RoleModel authRole = realm.getRole(configAuthRole);
|
||||||
if (authRole == null) {
|
if (authRole == null) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -68,6 +77,11 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
}
|
}
|
||||||
|
|
||||||
String configMatchRole = model.getConfig().getFirst("match-role");
|
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);
|
RoleModel matchRole = realm.getRole(configMatchRole);
|
||||||
if (matchRole == null) {
|
if (matchRole == null) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
|
|
@ -77,6 +91,10 @@ public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<Compon
|
||||||
UserProfileProvider profileProvider = session.getProvider(UserProfileProvider.class);
|
UserProfileProvider profileProvider = session.getProvider(UserProfileProvider.class);
|
||||||
UPConfig upconfig = profileProvider.getConfiguration();
|
UPConfig upconfig = profileProvider.getConfiguration();
|
||||||
String configAttributeGroup = model.getConfig().getFirst("attribute-group");
|
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))) {
|
if (!upconfig.getGroups().stream().anyMatch(g -> g.getName().equals(configAttributeGroup))) {
|
||||||
hasError = true;
|
hasError = true;
|
||||||
errorString += " • [Attribute Group] does not exist\n";
|
errorString += " • [Attribute Group] does not exist\n";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
Currently this gives us an ugly exception in the Keycloak logs for an empty slug, as
configAttributeSlugis thennull. Not critical as it still just errors, but we should probably check, ifconfigAttributeSlugisnull. I guess then adding a null check to all the otherconfig$things is probably a good idea as well.