Class BasicExpressionFunctions
The functions should be written to support scripting-like comfort. It means that they all needs to be null-safe, automatically convert data types as necessary and so on.
- Author:
- Radovan Semancik
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Trace
static final XMLGregorianCalendar
Special value that is too far in the past.static final String
-
Constructor Summary
ConstructorDescriptionBasicExpressionFunctions
(PrismContext prismContext, Protector protector, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionaddDuration
(XMLGregorianCalendar now, String duration) addDuration
(XMLGregorianCalendar now, Duration duration) addMillis
(XMLGregorianCalendar now, long duration) static String
Creates a valid LDAP distinguished name from the wide range of components.static String
composeDnWithSuffix
(Object... components) Creates a valid LDAP distinguished name from the wide range of components assuming that the last component is a suffix.concatName
(Object... components) Concatenates the arguments to create a name.boolean
boolean
containsIgnoreCase
(Object object, Object search) static String
static String
decrypt
(ProtectedStringType protectedString) determineLdapSingleAttributeValue
(String dn, String attributeName, Collection<?> values) determineLdapSingleAttributeValue
(Collection<String> dns, String attributeName, PrismProperty attribute) determineLdapSingleAttributeValue
(Collection<String> dns, String attributeName, Collection<String> values) boolean
endsWith
(PolyString polyString, String value) Checks whether the given normalized string ends with the specified valueboolean
Checks whether the given normalized string ends with the specified value by first normalizing it.formatDateTime
(String format, Long millis) formatDateTime
(String format, XMLGregorianCalendar xmlCal) getAttributeStringValues
(ShadowType shadow, groovy.namespace.QName attributeQname) getAttributeStringValues
(ShadowType shadow, String attributeNamespace, String attributeLocalPart) getAttributeStringValues
(ShadowType shadow, QName attributeQname) <T> T
getAttributeValue
(ShadowType shadow, groovy.namespace.QName attributeQname) <T> T
getAttributeValue
(ShadowType shadow, String attributeLocalPart) The namespace of the attribute is assumed to be "ri:"<T> T
getAttributeValue
(ShadowType shadow, String attributeNamespace, String attributeLocalPart) <T> T
getAttributeValue
(ShadowType shadow, QName attributeQname) <T> Collection<T>
getAttributeValues
(ShadowType shadow, groovy.namespace.QName attributeQname) <T> Collection<T>
getAttributeValues
(ShadowType shadow, String attributeLocalPart) <T> Collection<T>
getAttributeValues
(ShadowType shadow, String attributeNamespace, String attributeLocalPart) <T> Collection<T>
getAttributeValues
(ShadowType shadow, QName attributeQname) <T> T
getExtensionPropertyValue
(Containerable containerable, groovy.namespace.QName propertyQname) <T> T
getExtensionPropertyValue
(Containerable containerable, String localPart) <T> T
getExtensionPropertyValue
(Containerable containerable, String namespace, String localPart) <T> T
getExtensionPropertyValue
(Containerable containerable, QName propertyQname) <T> Collection<T>
getExtensionPropertyValues
(Containerable object, groovy.namespace.QName propertyQname) <T> Collection<T>
getExtensionPropertyValues
(Containerable containerable, String namespace, String localPart) <T> Collection<T>
getExtensionPropertyValues
(Containerable object, QName propertyQname) getExtensionReferenceValue
(ObjectType object, String namespace, String localPart) getExtensionReferenceValue
(ObjectType object, QName propertyQname) <T> T
getIdentifierValue
(ShadowType shadow) @NotNull Collection<?>
getMetadataExtensionValues
(PrismValue value, String itemLocalPart) Simplified version of getMetadataValue aimed at fetching single-segment extension paths.@NotNull Collection<?>
getMetadataValues
(PrismValue value, Object... pathSegments) Generic method to extract all metadata values pointed-to by given item path (specified as segments).@NotNull Collection<?>
getMetadataValues
(PrismValue value, String path) getOids
(ObjectReferenceType refs) getOids
(ObjectType refs) getOids
(Collection<ObjectReferenceType> refs) <T> T
getPropertyValue
(Containerable c, ItemPathType path) <T> T
getPropertyValue
(Containerable c, String path) <T> T
getPropertyValue
(PrismContainerValue<?> pcv, ItemPathType path) <T> T
getPropertyValue
(PrismContainerValue<?> pcv, String path) <T> Collection<T>
getPropertyValues
(Containerable c, ItemPathType path) <T> Collection<T>
getPropertyValues
(Containerable c, String path) <T> Collection<T>
getPropertyValues
(PrismContainerValue<?> pcv, ItemPathType path) <T> Collection<T>
getPropertyValues
(PrismContainerValue<?> pcv, String path) <T> T
getResourceIcfConfigurationPropertyValue
(ResourceType resource, String propertyLocalPart) <T> T
getResourceIcfConfigurationPropertyValue
(ResourceType resource, QName propertyQname) <T> T
hashLdapPassword
(byte[] clearBytes, String alg) Hashes cleartext password in an (unofficial) LDAP password format.hashLdapPassword
(ProtectedStringType protectedString, String alg) Hashes cleartext password in an (unofficial) LDAP password format.hashLdapPassword
(String clearString, String alg) Hashes cleartext password in an (unofficial) LDAP password format.boolean
static String
Convert string to lower case.longAgo()
norm
(PolyString orig) Normalize a PolyString value.norm
(PolyStringType orig) Normalize a PolyStringType value.Normalize a string value.parseAdditionalName
(Object fullName) parseDateTime
(String format, String stringDate) parseFamilyName
(Object fullName) parseGivenName
(Object fullName) parseHonorificPrefix
(Object fullName) parseHonorificSuffix
(Object fullName) parseNickName
(Object fullName) static String
void
setExtensionRealValues
(PrismContainerValue<?> containerValue, Map<String, Object> map) void
setTaskWorkerThreads
(@NotNull TaskType task, Integer value) Sets "worker threads" distribution parameter for the root task activity.boolean
startsWith
(PolyString polyString, String value) Checks whether the given normalized string begins with the specified value.boolean
startsWith
(String string, String value) Checks whether the given normalized string begins with the specified value by first normalizing it.Converts whatever it gets to a string.<T> T
toSingle
(Collection<T> values) static String
Remove whitespaces at the beginning and at the end of the string.static String
Convert string to upper case.
-
Field Details
-
NAME_SEPARATOR
- See Also:
-
LOGGER
-
LONG_AGO
Special value that is too far in the past. It can be returned from time-based expressions to make sure that the expression is always executed.
-
-
Constructor Details
-
BasicExpressionFunctions
-
-
Method Details
-
lc
Convert string to lower case. -
uc
Convert string to upper case. -
contains
-
containsIgnoreCase
-
trim
Remove whitespaces at the beginning and at the end of the string. -
concatName
Concatenates the arguments to create a name. Each argument is stringified, trimmed and the result is concatenated by spaces. -
startsWith
Checks whether the given normalized string begins with the specified value by first normalizing it.- Parameters:
string
- the stringvalue
- the value- Returns:
- true/false
-
startsWith
Checks whether the given normalized string begins with the specified value.- Parameters:
polyString
- the stringvalue
- the value- Returns:
- true/false
-
endsWith
Checks whether the given normalized string ends with the specified value by first normalizing it.- Parameters:
string
- the stringvalue
- the value- Returns:
- true/false
-
endsWith
Checks whether the given normalized string ends with the specified value- Parameters:
polyString
- the stringvalue
- the value- Returns:
- true/false
-
norm
Normalize a string value. It follows the default normalization algorithm used for PolyString values.- Parameters:
orig
- original value to normalize- Returns:
- normalized value
-
norm
Normalize a PolyString value.- Parameters:
orig
- original value to normalize- Returns:
- normalized value
-
norm
Normalize a PolyStringType value.- Parameters:
orig
- original value to normalize- Returns:
- normalized value
-
toAscii
-
stringify
Converts whatever it gets to a string. But it does it in a sensitive way. E.g. it tries to detect collections and returns the first element (if there is only one). Never returns null. Returns empty string instead. -
getOids
-
getOids
-
getOids
-
isEmpty
-
getPrismContext
-
getExtensionPropertyValues
public <T> Collection<T> getExtensionPropertyValues(Containerable containerable, String namespace, String localPart) -
getExtensionPropertyValues
public <T> Collection<T> getExtensionPropertyValues(Containerable object, groovy.namespace.QName propertyQname) -
getExtensionPropertyValues
-
getExtensionPropertyValue
public <T> T getExtensionPropertyValue(Containerable containerable, String localPart) throws SchemaException - Throws:
SchemaException
-
getExtensionPropertyValue
public <T> T getExtensionPropertyValue(Containerable containerable, String namespace, String localPart) throws SchemaException - Throws:
SchemaException
-
getExtensionReferenceValue
public Referencable getExtensionReferenceValue(ObjectType object, String namespace, String localPart) throws SchemaException - Throws:
SchemaException
-
getExtensionPropertyValue
public <T> T getExtensionPropertyValue(Containerable containerable, groovy.namespace.QName propertyQname) throws SchemaException - Throws:
SchemaException
-
getExtensionPropertyValue
public <T> T getExtensionPropertyValue(Containerable containerable, QName propertyQname) throws SchemaException - Throws:
SchemaException
-
getExtensionReferenceValue
public Referencable getExtensionReferenceValue(ObjectType object, QName propertyQname) throws SchemaException - Throws:
SchemaException
-
getPropertyValue
- Throws:
SchemaException
-
getPropertyValues
-
getPropertyValue
- Throws:
SchemaException
-
getPropertyValues
-
getPropertyValue
- Throws:
SchemaException
-
getPropertyValue
- Throws:
SchemaException
-
getPropertyValues
-
getPropertyValues
-
getAttributeValues
public <T> Collection<T> getAttributeValues(ShadowType shadow, String attributeNamespace, String attributeLocalPart) -
getAttributeValues
-
getAttributeValues
public <T> Collection<T> getAttributeValues(ShadowType shadow, groovy.namespace.QName attributeQname) -
getAttributeValues
-
getAttributeValue
public <T> T getAttributeValue(ShadowType shadow, String attributeNamespace, String attributeLocalPart) throws SchemaException - Throws:
SchemaException
-
getAttributeValue
The namespace of the attribute is assumed to be "ri:"- Throws:
SchemaException
-
getAttributeValue
public <T> T getAttributeValue(ShadowType shadow, groovy.namespace.QName attributeQname) throws SchemaException - Throws:
SchemaException
-
getAttributeValue
- Throws:
SchemaException
-
getAttributeStringValues
public Collection<String> getAttributeStringValues(ShadowType shadow, String attributeNamespace, String attributeLocalPart) -
getAttributeStringValues
public Collection<String> getAttributeStringValues(ShadowType shadow, groovy.namespace.QName attributeQname) -
getAttributeStringValues
-
getMetadataValues
@Experimental @NotNull public @NotNull Collection<?> getMetadataValues(PrismValue value, Object... pathSegments) Generic method to extract all metadata values pointed-to by given item path (specified as segments). Note: does not support multivalued containers withing the path (e.g. collecting transformation/source/name, where transformation/source is a multivalued container). -
getMetadataValues
@Experimental @NotNull public @NotNull Collection<?> getMetadataValues(PrismValue value, String path) -
getMetadataExtensionValues
@Experimental @NotNull public @NotNull Collection<?> getMetadataExtensionValues(PrismValue value, String itemLocalPart) Simplified version of getMetadataValue aimed at fetching single-segment extension paths. -
setExtensionRealValues
public void setExtensionRealValues(PrismContainerValue<?> containerValue, Map<String, Object> map) throws SchemaException- Throws:
SchemaException
-
getIdentifierValue
- Throws:
SchemaException
-
getSecondaryIdentifierValue
- Throws:
SchemaException
-
determineLdapSingleAttributeValue
public String determineLdapSingleAttributeValue(Collection<String> dns, String attributeName, PrismProperty attribute) throws NamingException - Throws:
NamingException
-
getResourceIcfConfigurationPropertyValue
public <T> T getResourceIcfConfigurationPropertyValue(ResourceType resource, QName propertyQname) throws SchemaException - Throws:
SchemaException
-
getResourceIcfConfigurationPropertyValue
public <T> T getResourceIcfConfigurationPropertyValue(ResourceType resource, String propertyLocalPart) throws SchemaException - Throws:
SchemaException
-
determineLdapSingleAttributeValue
public String determineLdapSingleAttributeValue(Collection<String> dns, String attributeName, Collection<String> values) throws NamingException - Throws:
NamingException
-
determineLdapSingleAttributeValue
public String determineLdapSingleAttributeValue(String dn, String attributeName, Collection<?> values) throws NamingException - Throws:
NamingException
-
toSingle
- Throws:
SchemaException
-
readFile
- Throws:
IOException
-
formatDateTime
-
formatDateTime
-
parseDateTime
- Throws:
ParseException
-
currentDateTime
-
fromNow
-
addDuration
-
addDuration
-
addMillis
-
roundDownToMidnight
-
roundUpToEndOfDay
-
longAgo
-
parseGivenName
-
parseFamilyName
-
parseAdditionalName
-
parseNickName
-
parseHonorificPrefix
-
parseHonorificSuffix
-
decrypt
-
encrypt
-
composeDn
Creates a valid LDAP distinguished name from the wide range of components. The method can be invoked in many ways, e.g.:composeDn("cn","foo","o","bar") composeDn("cn","foo",new Rdn("o","bar")) composeDn(new Rdn("cn","foo"),"ou","baz",new Rdn("o","bar")) composeDn(new Rdn("cn","foo"),"ou","baz","o","bar") composeDn(new Rdn("cn","foo"),new LdapName("ou=baz,o=bar")) composeDn("cn","foo",new LdapName("ou=baz,o=bar"))
Note: the DN is not normalized. The case of the attribute names and white spaces are preserved.
- Throws:
InvalidNameException
-
composeDnWithSuffix
Creates a valid LDAP distinguished name from the wide range of components assuming that the last component is a suffix. The method can be invoked in many ways, e.g.:composeDn("cn","foo","o=bar") composeDn(new Rdn("cn","foo"),"ou=baz,o=bar") composeDn(new Rdn("cn","foo"),new LdapName("ou=baz,o=bar")) composeDn("cn","foo",new LdapName("ou=baz,o=bar"))
The last element is a complete suffix represented either as String or LdapName.
Note: the DN is not normalized. The case of the attribute names and white spaces are preserved.
- Throws:
InvalidNameException
-
hashLdapPassword
public String hashLdapPassword(ProtectedStringType protectedString, String alg) throws NoSuchAlgorithmException, EncryptionException Hashes cleartext password in an (unofficial) LDAP password format. Supported algorithms: SSHA, SHA and MD5. -
hashLdapPassword
Hashes cleartext password in an (unofficial) LDAP password format. Supported algorithms: SSHA, SHA and MD5.- Throws:
NoSuchAlgorithmException
-
hashLdapPassword
Hashes cleartext password in an (unofficial) LDAP password format. Supported algorithms: SSHA, SHA and MD5.- Throws:
NoSuchAlgorithmException
-
debugDump
-
debugDump
-
setTaskWorkerThreads
Sets "worker threads" distribution parameter for the root task activity.
-