diff --git a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java index 4d7ea13cee8049f582fa576a627bbcc4adad3172..76bdd86073f0044629be76d47b6327bab33f7407 100644 --- a/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java +++ b/ozgcloud-keycloak-operator/src/main/java/de/ozgcloud/operator/keycloak/realm/KeycloakRealmMapper.java @@ -38,26 +38,33 @@ import org.mapstruct.ReportingPolicy; @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, unmappedSourcePolicy = ReportingPolicy.IGNORE) interface KeycloakRealmMapper { + public static final String ACTION_TOKEN_GENERATED_BY_USER_LIFE_SPAN = "900"; + public static final String PASSWORD_POLICY = "upperCase(1) and lowerCase(1) and length(8) and notUsername"; + public static final String DEFAULT_LOCAL = "de"; + public static final String RESET_PASSWORD_ALLOWED = "true"; + public static final String ENABLED = "true"; + public static final String INTERNATIONALIZATION_ENABLED = "true"; + @Mapping(target = "displayName", source = "displayName") - @Mapping(target = "enabled", constant = "true") - @Mapping(target = "resetPasswordAllowed", constant = "true") + @Mapping(target = "enabled", constant = ENABLED) + @Mapping(target = "resetPasswordAllowed", constant = RESET_PASSWORD_ALLOWED) @Mapping(target = "supportedLocales", source = ".", qualifiedByName = "supportedLocales") - @Mapping(target = "defaultLocale", constant = "de") - @Mapping(target = "internationalizationEnabled", constant = "true") - @Mapping(target = "passwordPolicy", constant = "upperCase(1) and lowerCase(1) and length(8) and notUsername") - @Mapping(target = "actionTokenGeneratedByUserLifespan", constant = "900") + @Mapping(target = "defaultLocale", constant = DEFAULT_LOCAL) + @Mapping(target = "internationalizationEnabled", constant = INTERNATIONALIZATION_ENABLED) + @Mapping(target = "passwordPolicy", constant = PASSWORD_POLICY) + @Mapping(target = "actionTokenGeneratedByUserLifespan", constant = ACTION_TOKEN_GENERATED_BY_USER_LIFE_SPAN) @Mapping(target = "smtpServer", source = "smtpServer", qualifiedByName = "smtpServer") @Mapping(target = "roles.realm", source = "realmRoles") public RealmRepresentation map(OzgCloudKeycloakRealmSpec realm); @Mapping(target = "displayName", source = "displayName") - @Mapping(target = "enabled", constant = "true") - @Mapping(target = "resetPasswordAllowed", constant = "true") + @Mapping(target = "enabled", constant = ENABLED) + @Mapping(target = "resetPasswordAllowed", constant = RESET_PASSWORD_ALLOWED) @Mapping(target = "supportedLocales", source = ".", qualifiedByName = "supportedLocales") - @Mapping(target = "defaultLocale", constant = "de") - @Mapping(target = "internationalizationEnabled", constant = "true") - @Mapping(target = "passwordPolicy", constant = "upperCase(1) and lowerCase(1) and length(8) and notUsername") - @Mapping(target = "actionTokenGeneratedByUserLifespan", constant = "900") + @Mapping(target = "defaultLocale", constant = DEFAULT_LOCAL) + @Mapping(target = "internationalizationEnabled", constant = INTERNATIONALIZATION_ENABLED) + @Mapping(target = "passwordPolicy", constant = PASSWORD_POLICY) + @Mapping(target = "actionTokenGeneratedByUserLifespan", constant = ACTION_TOKEN_GENERATED_BY_USER_LIFE_SPAN) @Mapping(target = "smtpServer", source = "smtpServer", qualifiedByName = "smtpServer") @Mapping(target = "roles.realm", source = "realmRoles") RealmRepresentation update(@MappingTarget RealmRepresentation existingRealm, OzgCloudKeycloakRealmSpec spec);