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, @NotNull String localPart) <T> T
getExtensionPropertyValue
(Containerable containerable, groovy.namespace.QName propertyQname) <T> T
getExtensionPropertyValue
(Containerable containerable, String namespace, @NotNull String localPart) <T> T
getExtensionPropertyValue
(Containerable containerable, QName propertyQname) Returns the real value of an extension property (of an object, assignment, or similar structure), ornull
if no value exists.<T> @NotNull Collection<T>
getExtensionPropertyValues
(Containerable object, groovy.namespace.QName propertyQname) <T> @NotNull Collection<T>
getExtensionPropertyValues
(Containerable containerable, String namespace, @NotNull String localPart) Returns real values of an extension property (of an object, assignment, or similar structure).<T> @NotNull Collection<T>
getExtensionPropertyValues
(Containerable object, QName propertyQname) @Nullable Referencable
getExtensionReferenceValue
(Containerable containerable, String namespace, @NotNull String localPart) @Nullable Referencable
getExtensionReferenceValue
(Containerable containerable, QName itemQName) Returns the value of an extension reference item (of an object, assignment, or similar structure), ornull
if no value exists.<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
Beware, the shadow may legally have more than one secondary identifier.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
resolveSecretBinary
(@NotNull String provider, @NotNull String key) resolveSecretString
(@NotNull String provider, @NotNull String key) void
setExtensionPropertyValues
(@NotNull Containerable parent, @NotNull String propertyName, Object... values) void
setExtensionPropertyValues
(@NotNull Containerable parent, @NotNull QName propertyName, Object... values) Sets the real values of a given extension property (of an object, assignment, or similar structure).void
setExtensionRealValues
(PrismContainerValue<?> containerValue, Map<String, Object> map) Deprecated.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
@NotNull public <T> @NotNull Collection<T> getExtensionPropertyValues(Containerable containerable, String namespace, @NotNull @NotNull String localPart) Returns real values of an extension property (of an object, assignment, or similar structure). Do not modify the returned collection. -
getExtensionPropertyValues
@NotNull public <T> @NotNull Collection<T> getExtensionPropertyValues(Containerable object, @NotNull groovy.namespace.QName propertyQname) -
getExtensionPropertyValues
@NotNull public <T> @NotNull Collection<T> getExtensionPropertyValues(Containerable object, @NotNull QName propertyQname) -
getExtensionPropertyValue
@Nullable public <T> T getExtensionPropertyValue(Containerable containerable, @NotNull QName propertyQname) throws SchemaException Returns the real value of an extension property (of an object, assignment, or similar structure), ornull
if no value exists. Throws aSchemaException
if the property has multiple values.- Throws:
SchemaException
-
getExtensionPropertyValue
@Nullable public <T> T getExtensionPropertyValue(Containerable containerable, @NotNull @NotNull String localPart) throws SchemaException - Throws:
SchemaException
- See Also:
-
getExtensionPropertyValue
@Nullable public <T> T getExtensionPropertyValue(Containerable containerable, String namespace, @NotNull @NotNull String localPart) throws SchemaException - Throws:
SchemaException
- See Also:
-
getExtensionPropertyValue
@Nullable public <T> T getExtensionPropertyValue(Containerable containerable, @NotNull groovy.namespace.QName propertyQname) throws SchemaException - Throws:
SchemaException
- See Also:
-
getExtensionReferenceValue
@Nullable public @Nullable Referencable getExtensionReferenceValue(Containerable containerable, @NotNull QName itemQName) throws SchemaException Returns the value of an extension reference item (of an object, assignment, or similar structure), ornull
if no value exists. Throws aSchemaException
if the item has multiple values.- Throws:
SchemaException
-
getExtensionReferenceValue
@Nullable public @Nullable Referencable getExtensionReferenceValue(Containerable containerable, String namespace, @NotNull @NotNull String localPart) throws SchemaException - Throws:
SchemaException
- See Also:
-
setExtensionPropertyValues
public void setExtensionPropertyValues(@NotNull @NotNull Containerable parent, @NotNull @NotNull QName propertyName, Object... values) throws SchemaException Sets the real values of a given extension property (of an object, assignment, or similar structure). Removes any existing values.- Throws:
SchemaException
-
setExtensionPropertyValues
public void setExtensionPropertyValues(@NotNull @NotNull Containerable parent, @NotNull @NotNull String propertyName, Object... values) throws SchemaException - Throws:
SchemaException
- See Also:
-
setExtensionRealValues
@Deprecated public void setExtensionRealValues(PrismContainerValue<?> containerValue, Map<String, Object> map) throws SchemaExceptionDeprecated.- 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. -
getIdentifierValue
- Throws:
SchemaException
-
getSecondaryIdentifierValue
Beware, the shadow may legally have more than one secondary identifier.- Throws:
SchemaException
-
determineLdapSingleAttributeValue
public String determineLdapSingleAttributeValue(Collection<String> dns, String attributeName, PrismProperty attribute) throws NamingException - Throws:
NamingException
-
getResourceIcfConfigurationPropertyValue
-
getResourceIcfConfigurationPropertyValue
public <T> T getResourceIcfConfigurationPropertyValue(ResourceType resource, String propertyLocalPart) -
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
-
resolveSecretString
-
resolveSecretBinary
public ByteBuffer resolveSecretBinary(@NotNull @NotNull String provider, @NotNull @NotNull String key) -
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.
-