Package org.keycloak.userprofile.config
Class UPConfigUtils
- java.lang.Object
- 
- org.keycloak.userprofile.config.UPConfigUtils
 
- 
 public class UPConfigUtils extends Object Utility methods to work with User Profile Configurations- Author:
- Vlastimil Elias 
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringROLE_ADMINstatic StringROLE_USER
 - 
Constructor SummaryConstructors Constructor Description UPConfigUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanBeAuthFlowContext(UserProfileContext context)Check if context CAN BE part of the AuthenticationFlow.static StringcapitalizeFirstLetter(String str)static List<String>getChunks(String src, int partLength)Break string to substrings of given length.static booleanisRoleForContext(UserProfileContext context, Set<String> roles)Check if roles configuration contains role given current context.static booleanisValidAttributeName(String attributeName)static UPConfigreadConfig(InputStream is)Load configuration from JSON file.static StringreadDefaultConfig()static List<String>validate(KeycloakSession session, UPConfig config)Validate object representation of the configuration.
 
- 
- 
- 
Field Detail- 
ROLE_USERpublic static final String ROLE_USER - See Also:
- Constant Field Values
 
 - 
ROLE_ADMINpublic static final String ROLE_ADMIN - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
readConfigpublic static UPConfig readConfig(InputStream is) throws IOException Load configuration from JSON file.Configuration is not validated, use validate(KeycloakSession, UPConfig)to validate it and get list of errors.- Parameters:
- is- JSON file to be loaded
- Returns:
- object representation of the configuration
- Throws:
- IOException- if JSON configuration can't be loaded (eg due to JSON format errors etc)
 
 - 
validatepublic static List<String> validate(KeycloakSession session, UPConfig config) Validate object representation of the configuration. Validations:- defaultProfile is defined and exists in profiles
- parent exists for type
- type exists for attribute
- validator (from Validator SPI) exists for validation and it's config is correct
- if an attribute group is configured it is verified that this group exists
- all groups have a name != null
 - Parameters:
- session- to be used for Validator SPI integration
- config- to validate
- Returns:
- list of errors, empty if no error found
 
 - 
isValidAttributeNamepublic static boolean isValidAttributeName(String attributeName) - Parameters:
- attributeName- to validate
- Returns:
 
 - 
getChunkspublic static List<String> getChunks(String src, int partLength) Break string to substrings of given length.- Parameters:
- src- to break
- partLength-
- Returns:
- list of string parts, never null (but can be empty if src is null)
 
 - 
canBeAuthFlowContextpublic static boolean canBeAuthFlowContext(UserProfileContext context) Check if context CAN BE part of the AuthenticationFlow.- Parameters:
- context- to check
- Returns:
- true if context CAN BE part of the auth flow
 
 - 
isRoleForContextpublic static boolean isRoleForContext(UserProfileContext context, Set<String> roles) Check if roles configuration contains role given current context.- Parameters:
- context- to be checked
- roles- to be inspected
- Returns:
- true if roles list contains role representing checked context
 
 - 
readDefaultConfigpublic static String readDefaultConfig() 
 
- 
 
-