Class Utils
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final Pattern
static final String
static final Pattern
Integer row mapperstatic final DateTimeFormatter
static final String
static final Pattern
String row mapperstatic final String
static final String
static final Pattern
static final Pattern
static final Pattern
static final Pattern
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Get BigDecimal number like '1024' in Bytes and create better readable String with metric value like '1K' where K means KiloBytes.static void
checkDestination
(Destination destination) Checks whether the destinations name has correct syntax.static void
checkDestinationType
(Destination destination) Checks whether the destination is not null and is of the right type.static void
checkHostname
(Host host) Checks whether the hostname has correct syntax.static void
checkMaxLength
(String propertyName, String actualValue, int maxLength) Throws a MaxSizeExceededException if the given value is longer than maxLength.static void
checkMinLength
(String propertyName, String actualValue, int minLength) Throws a MinSizeExceededException if the given value does not specified minLength.static void
static void
checkRangeOfNumbers
(int number, int lowestValue, int highestValue) Define, if some number is in range.static void
checkWithoutDiacritic
(String name) Define, if some entity contain a diacritic symbol.static void
checkWithoutNumbers
(String name) Define, if some entity contain a numberstatic void
checkWithoutSpaces
(String name) Define, if some entity contain a spacestatic void
Define, if some entity contain a special symbol Special symbol is everything except - numbers, letters and spacestatic void
checkWithoutSpecialChars
(String name, String allowedSpecialChars) Define, if some entity contain a special symbol Special symbol is everything except - numbers, letters and space (and allowedSpecialChars) The allowedSpecialChars are on the end of regular expresion, so the same rule must be observed.static boolean
checkWordInSortedFile
(String filename, String word) Performs binary search for EXACT match in SORTED ascii file.static String
cipherInput
(String plainText, boolean decrypt) Return en/decrypted version of input using AES/CBC/PKCS5PADDING cipher.static Attribute
copyAttributeToViAttributeWithoutValue
(Attribute copyFrom, Attribute copyTo) static Attribute
copyAttributeToVirtualAttributeWithValue
(Attribute copyFrom, Attribute copyTo) createDeepCopyOfMapWithSets
(Map<T, Set<T>> original) Creates copy of given Map with Sets as values.static User
createUserFromNameMap
(Map<String, String> name) static User
createUserFromNameMap
(Map<String, String> name, boolean allowEmptyFirstName) static String
escapeStringForLDAP
(String searchString) We need to escape some special characters for LDAP filtering.static LocalDate
extendDateByPeriod
(LocalDate localDate, String period) Extends given date by given period.static List
<RichUserExtSource> extractAdditionalUserExtSources
(PerunSession sess, Map<String, String> subjectFromExtSource) Returns additionalUserExtSources from the subject.generateStringsByPattern
(String pattern) Method generates strings by pattern.getAttributesQuery
(List<String> memberAttributes, List<String> userAttributes, List<String> uesAttributes) Prepares query to search users or members by attributes if received attribute list is not empty.getClasses
(String packageName) Scans all classes accessible from the context class loader which belong to the given package and subpackages.static LocalDate
Returns closest future LocalDate based on values given by matcher.Takes attributes from CoreConfig used in users or members search and divides them into correct categories based on attribute type (member, user, userExtSource).static MapSqlParameterSource
getMapSqlParameterSourceToSearchUsersOrMembers
(String searchString, Map<String, List<String>> attributesToSearchBy) Returns MapSqlParameterSource with values added to search members or users.static String
Return encrypted version of input in UTF-8 by HmacSHA256static int
getNewId
(JdbcTemplate jdbc, String sequenceName) Gets the next number from the sequence.static long
getRunningTime
(long startTime) Returns difference between startTime and current time in millis.static <T> boolean
hasDuplicate
(List<T> all) static boolean
Return true, if char on position in text is escaped by '\' Return false, if not.static boolean
isUserRelatedAttribute
(AttributeDefinition attribute) Returns true if given attribute is user-related (it is user, user_facility, member, member_group, member_resource or ues attribute).static String
Joins Strings or any objects into a String.static String
Joins Strings or any objects into a String.static String
normalizeString
(String str) Replaces dangerous characters.static void
Checks whether the object is null or not.parseCommonName
(String rawName) parseCommonName
(String rawName, boolean fullNameRequired) Try to parse rawName to keys: "titleBefore" "firstName" "lastName" "titleAfter"static User
parseUserFromCommonName
(String rawName, boolean fullNameRequired) Creates a new instance of User with names initialized from parsed rawName.static String
Returns search query to search by application's form data values based on databased in use.static Pair
<Integer, TemporalUnit> prepareGracePeriodDate
(Matcher matcher) Prepares grace period date by values from given matcher.static String
Returns search query to search by group name or description (similar match) based on databased in use.static String
Returns search query to search by group name or description (similar match) based on databased in use.static String
Returns search query to search by receiver name or email (similar match) based on databased in use.static String
Returns search query to search by sender name or email (similar match) based on databased in use.static String
prepareSqlWhereForApplicationsSearch
(String searchString, MapSqlParameterSource namedParams) Returns a part of WHERE condition to search applications in their ids, username, group ids/uuids, names and description by given search string.static String
prepareSqlWhereForGroupSearch
(String searchString, MapSqlParameterSource namedParams, boolean subgroups) Returns a part of WHERE condition to search groups in their ids, uuids, names and descriptions by given search string.static String
prepareSqlWhereForInvitationSearch
(String searchString, MapSqlParameterSource namedParams) Returns a part of WHERE condition to search invitations in their ids, receiver's name and receiver's email by given search string.static String
prepareSqlWhereForUserMemberSearch
(String searchString, MapSqlParameterSource namedParams, boolean exactMatch) Returns a part of WHERE condition to search users and members in their ids, uuids, logins, ext sources user names and attributes by given search string.static String
Returns search query to search by subgroup name or description (similar match) based on databased in use.static String
Returns search query to search by user name based on databased in use.static String
Returns search query to search by user name (exact match) based on databased in use.static String
Returns search query to search by user name (similar match) based on databased in use.static void
sendAccountActivationConfirmationEmail
(User user, String email, String namespace, String login, String subject, String content) Sends email to user confirming his password was set and the account was activated.static void
sendAccountActivationEmail
(User user, String email, String login, String namespace, String url, UUID uuid, String messageTemplate, String subject, LocalDateTime validityTo) Sends email with link to non-authz account activation where user can activate his account by setting a password.static void
sendIdentityAddedAlerts
(PerunSession sess, UserExtSource newUes) Sends all alerts about an identity being added.static void
sendIdentityRemovedAlerts
(PerunSession sess, UserExtSource removedUes, List<Attribute> uesAttrs) Sends all alerts about an identity being removed.static void
sendPasswordResetConfirmationEmail
(User user, String email, String namespace, String login, String subject, String content) Sends email to user confirming his password was changed.static void
sendPasswordResetEmail
(User user, String email, String namespace, String url, UUID uuid, String messageTemplate, String subject, LocalDateTime validityTo) Sends email with link to non-authz password reset GUI where user can reset forgotten passwordstatic void
sendSMS
(PerunSession sess, Member member, String message) Sends SMS to the phone number of a member with the given message.static void
sendSMS
(PerunSession sess, User user, String message) Sends SMS to the phone number of a user with the given message.static void
Sends SMS to the phone number with the given message.static void
sendUsernameReminderEmail
(User user, String email, String login, String namespace, String messageTemplate, String subject) Sends email with reminder of the username in the specified namespace to the userstatic void
sendValidationEmail
(User user, String url, String email, UUID changeUuid, String subject, String content, String customUrlPath, String idp) Send validation email related to requested change of users preferred email.static String
serializeMapToString
(Map<String, String> map) Serialize map to stringstatic LocalDate
shortenDateByPeriod
(LocalDate localDate, String period) Shortens the given date by the given period.static long
Returns current time in millis.static String
Convert input string (expected UTF-8) to ASCII if possible.static void
validateFullGroupName
(String name) static void
validateGroupName
(String name) Validates group name.static void
validateGroupName
(String name, String regex) Validates given group name against a given regex.static void
validateSSHPublicKey
(String sshKey)
-
Field Details
-
CONFIGURATIONS_LOCATIONS
- See Also:
-
TITLE_BEFORE
- See Also:
-
FIRST_NAME
- See Also:
-
LAST_NAME
- See Also:
-
TITLE_AFTER
- See Also:
-
EMAIL_PATTERN
-
UCO_EMAIL_PATTERN
-
LAST_ACCESS_FORMATTER
-
HOST_PATTERN
-
URL_PATTERN
-
USER_AT_HOST_PATTERN
-
USER_AT_HOST_PORT_PATTERN
-
SERVICE_SPECIFIC_PATTERN
-
ID_MAPPER
Integer row mapper -
STRING_MAPPER
String row mapper
-
-
Method Details
-
normalizeString
Replaces dangerous characters. Replaces : with - and spaces with _.- Parameters:
str
- string to be normalized- Returns:
- normalized string
-
hasDuplicate
-
extractAdditionalUserExtSources
public static List<RichUserExtSource> extractAdditionalUserExtSources(PerunSession sess, Map<String, String> subjectFromExtSource) Returns additionalUserExtSources from the subject. It's used for synchronization from different ExtSources. subjectFromExtSource was obtained from the ExtSource. This additional userExtSource has 3 required parts: name of extSource, type of extSource, login of extsource with optional ues attributes and their values. And 1 optional part: LoA. Expected format of additional userExtSource is: extSourceName|extSourceType|extLogin;uesAttribute1=value1, value2;uesAttribute2=value1|LoA- Parameters:
sess
- perun sessionsubjectFromExtSource
- map with the subject- Returns:
- List
all additional ExtSources (and possibly their attributes) from the subject, returned list will never contain null value
-
join
Joins Strings or any objects into a String. Use asString[] sa = { "a", "b", "c"}; String s = join(list,",");
- Parameters:
objs
- array of objectsseparator
- any separator, like a comma- Returns:
- string with string representations of objects joined by separators
-
join
Joins Strings or any objects into a String. Use asListinvalid input: '<'?> list = Arrays.asList("a", 1, 2.0); String s = join(list,",");
- Parameters:
collection
- anything Iterable, like aList
orCollection
separator
- any separator, like a comma- Returns:
- string with string representations of objects joined by separators
-
checkPerunSession
-
notNull
Checks whether the object is null or not.- Parameters:
e
-name
-- Throws:
InternalErrorException
- which wraps NullPointerException
-
createDeepCopyOfMapWithSets
Creates copy of given Map with Sets as values. The returned object contains a new Map and new Sets, theUtils
objects remain the same.- Type Parameters:
T
- parameter- Parameters:
original
- original Map- Returns:
- new Map with new Sets as values
-
checkMinLength
Throws a MinSizeExceededException if the given value does not specified minLength. If the value is null then MinSizeExceededException is thrown as well.- Parameters:
propertyName
- name of checked propertyminLength
- minimal length- Throws:
MinSizeExceededException
- when length of actualValue is lower than minLength or null
-
checkMaxLength
Throws a MaxSizeExceededException if the given value is longer than maxLength. If the value is null then nothing happens.- Parameters:
propertyName
- name of checked propertymaxLength
- max length- Throws:
MaxSizeExceededException
- when length of actualValue is higher than maxLength
-
checkWithoutDiacritic
Define, if some entity contain a diacritic symbol.- Parameters:
name
- name of entity- Throws:
DiacriticNotAllowedException
-
checkWithoutSpecialChars
Define, if some entity contain a special symbol Special symbol is everything except - numbers, letters and space- Parameters:
name
- name of entity- Throws:
SpecialCharsNotAllowedException
-
checkWithoutSpecialChars
Define, if some entity contain a special symbol Special symbol is everything except - numbers, letters and space (and allowedSpecialChars) The allowedSpecialChars are on the end of regular expresion, so the same rule must be observed. (example, symbol - must be on the end of string) rules are the same like in regular expresion- Parameters:
name
- name of entityallowedSpecialChars
- this String must contain only special chars which are allowed- Throws:
SpecialCharsNotAllowedException
-
checkWithoutNumbers
Define, if some entity contain a number- Parameters:
name
-- Throws:
NumbersNotAllowedException
-
checkWithoutSpaces
Define, if some entity contain a space- Parameters:
name
-- Throws:
SpaceNotAllowedException
-
checkRangeOfNumbers
public static void checkRangeOfNumbers(int number, int lowestValue, int highestValue) Define, if some number is in range. Example: number 4 is in range 4 - 12, number 3 is not- Parameters:
number
-lowestValue
-highestValue
-- Throws:
NumberNotInRangeException
-
getNewId
Gets the next number from the sequence.- Parameters:
jdbc
-sequenceName
-- Returns:
- new ID
- Throws:
InternalErrorException
-
startTimer
public static long startTimer()Returns current time in millis. Result of this call can then be used by function getRunningTime().- Returns:
- current time in millis.
-
getRunningTime
public static long getRunningTime(long startTime) Returns difference between startTime and current time in millis.- Parameters:
startTime
-- Returns:
- difference between current time in millis and startTime.
-
getClasses
public static List<Class<?>> getClasses(String packageName) throws ClassNotFoundException, IOException Scans all classes accessible from the context class loader which belong to the given package and subpackages.- Parameters:
packageName
- The base package- Returns:
- The classes
- Throws:
ClassNotFoundException
IOException
-
createUserFromNameMap
-
createUserFromNameMap
-
parseUserFromCommonName
Creates a new instance of User with names initialized from parsed rawName. Imposes limit on lengths of fields.- Parameters:
rawName
- raw namefullNameRequired
- if true, throw exception if firstName or lastName is missing, do not throw exception otherwise- Returns:
- User
- See Also:
-
parseCommonName
- See Also:
-
parseCommonName
Try to parse rawName to keys: "titleBefore" "firstName" "lastName" "titleAfter"If rawName is null or empty, return map with empty values of all keys.
Parsing procedure: 1] prepare list of parts by replacing all characters "," and "_" by spaces 2] change all sequence of invisible characters (space, tabulator etc.) to one space 3] one by one try to parsing parts from the list - A] try to find all titleBefore parts - B] try to find one firstName part - C] try to find all lastName parts - D] if the rest is not lastName so save it to the title after
Example of parsing rawName: 1] rawName = "Mgr. et Mgr. Petr_Jiri R. Sojka, Ph.D., CSc." 2] convert all ',' and '_' to spaces: rawName = "Mgr. et Mgr. Petr Jiri R. Sojka Ph.D. CSc." 3] convert more than 1 invisible char to 1 space: rawName = "Mgr. et Mgr. Petr Jiri R. Sojka Ph.D. CSc." 4] parse string to list of parts by space: ListOfParts= ["Mgr.","et","Mgr.","Petr","Jiri","R.","Sojka","Ph.D.", "CSc."] 5] first fill everything what can be in title before: titleBefore="Mgr. et Mgr." 6] then fill everything what can be in first name (maximum 1 part): firstName="Petr" 7] then fill everything what can be in last name: lastName="Jiri R. Sojka" 8] everything else put to the title after: titleAfter="Ph.D. CSc." 9] put these variables to map like key=value, for ex.: Map[titleBefore="Mgr. et Mgr.",firstName="Petr", ... ] and return this map
- Parameters:
rawName
- name to parsefullNameRequired
- if true, throw exception if firstName or lastName is missing, do not throw exception otherwise- Returns:
- map string to string where are 4 keys (titleBefore,titleAfter,firstName and lastName) with their values (value can be null)
- Throws:
ParseUserNameException
- when method was unable to parse both first name and last name from the rawName
-
isEscaped
Return true, if char on position in text is escaped by '\' Return false, if not.- Parameters:
text
- text in which will be searchingposition
- position in text invalid input: '<'0-text.length>- Returns:
- true if char is escaped, false if not
-
serializeMapToString
Serialize map to string- Parameters:
map
-- Returns:
- string of escaped map
-
copyAttributeToViAttributeWithoutValue
-
copyAttributeToVirtualAttributeWithValue
-
generateStringsByPattern
Method generates strings by pattern. The pattern is string with square brackets, e.g. "a[1-3]b". Then the content of the brackets is distributed, so the list is [a1b, a2b, a3c]. Multibrackets are aslo allowed. For example "a[00-01]b[90-91]c" generates [a00b90c, a00b91c, a01b90c, a01b91c].- Parameters:
pattern
-- Returns:
- list of all generated strings
- Throws:
WrongPatternException
-
getMessageAuthenticationCode
Return encrypted version of input in UTF-8 by HmacSHA256- Parameters:
input
- input to encrypt- Returns:
- encrypted value
-
sendValidationEmail
public static void sendValidationEmail(User user, String url, String email, UUID changeUuid, String subject, String content, String customUrlPath, String idp) Send validation email related to requested change of users preferred email.- Parameters:
user
- user to change preferred email forurl
- base URL of running perun instance passed from RPCemail
- new email address to send notification tochangeUuid
- UUID of change request in DBsubject
- Template subject or nullcontent
- Template message or nullcustomUrlPath
- custom path to be used in generated URLidp
- Authentication to be added as query parameter in generated URL
-
sendUsernameReminderEmail
public static void sendUsernameReminderEmail(User user, String email, String login, String namespace, String messageTemplate, String subject) Sends email with reminder of the username in the specified namespace to the user- Parameters:
user
- user to send notification foremail
- user's email to send notification tologin
- user's login which will be used in message, if tag{login}
is used.namespace
- namespace to reset password inmessageTemplate
- message of the email (uses default if null)subject
- subject of the email (uses default if null)
-
sendAccountActivationEmail
public static void sendAccountActivationEmail(User user, String email, String login, String namespace, String url, UUID uuid, String messageTemplate, String subject, LocalDateTime validityTo) Sends email with link to non-authz account activation where user can activate his account by setting a password.- Parameters:
user
- user to send notification foremail
- user's email to send notification tologin
- user's login which will be used in message, if tag{login}
is used.namespace
- namespace to reset password inurl
- base URL of Perun instanceuuid
- UUID of account activation requestmessageTemplate
- message of the email (use default if null)subject
- subject of the email (use default if null)validityTo
- time till link is valid
-
sendPasswordResetEmail
public static void sendPasswordResetEmail(User user, String email, String namespace, String url, UUID uuid, String messageTemplate, String subject, LocalDateTime validityTo) Sends email with link to non-authz password reset GUI where user can reset forgotten password- Parameters:
user
- user to send notification foremail
- user's email to send notification tonamespace
- namespace to reset password inurl
- base URL of Perun instanceuuid
- UUID of pwd reset requestmessageTemplate
- message of the emailsubject
- subject of the emailvalidityTo
- time till link is valid- Throws:
InternalErrorException
-
sendAccountActivationConfirmationEmail
public static void sendAccountActivationConfirmationEmail(User user, String email, String namespace, String login, String subject, String content) Sends email to user confirming his password was set and the account was activated.- Parameters:
user
- user to send notification foremail
- user's email to send notification tonamespace
- namespace where the account was activatedlogin
- login of usersubject
- Subject from template or nullcontent
- Message from template or null
-
sendPasswordResetConfirmationEmail
public static void sendPasswordResetConfirmationEmail(User user, String email, String namespace, String login, String subject, String content) Sends email to user confirming his password was changed.- Parameters:
user
- user to send notification foremail
- user's email to send notification tonamespace
- namespace the password was re-setlogin
- login of usersubject
- Subject from template or nullcontent
- Message from template or null
-
cipherInput
Return en/decrypted version of input using AES/CBC/PKCS5PADDING cipher. Perun's internal secretKey and initVector are used (you can configure them in perun.properties file).- Parameters:
plainText
- text to en/decryptdecrypt
- TRUE = decrypt input / FALSE = encrypt input- Returns:
- en/decrypted text
- Throws:
InternalErrorException
- if anything fails
-
checkDestinationType
Checks whether the destination is not null and is of the right type.- Parameters:
destination
- destination to check- Throws:
InternalErrorException
- if destination is nullWrongPatternException
- if destination is not of the right type
-
checkDestination
Checks whether the destinations name has correct syntax.- Parameters:
destination
- destination to check- Throws:
IllegalArgumentException
- if destination has invalid value in given destination type.
-
checkHostname
Checks whether the hostname has correct syntax.- Parameters:
host
- host to check- Throws:
IllegalArgumentException
- if host has invalid hostname
-
sendSMS
public static void sendSMS(PerunSession sess, User user, String message) throws PrivilegeException, UserNotExistsException Sends SMS to the phone number of a user with the given message. The phone number is taken from the user attribute urn:perun:user:attribute-def:def:phone.- Parameters:
sess
- sessionuser
- receiver of the messagemessage
- sms message to send- Throws:
InternalErrorException
- when the attribute value cannot be found or is brokenPrivilegeException
- when the actor has not right to get the attributeUserNotExistsException
- when given user does not exist
-
sendSMS
public static void sendSMS(PerunSession sess, Member member, String message) throws PrivilegeException, MemberNotExistsException Sends SMS to the phone number of a member with the given message. The phone number is taken from the user attribute urn:perun:member:attribute-def:def:phone.- Parameters:
sess
- sessionmember
- receiver of the messagemessage
- sms message to send- Throws:
InternalErrorException
- when the attribute value cannot be found or is brokenPrivilegeException
- when the actor has not right to get the attributeMemberNotExistsException
- when given member does not exist
-
sendSMS
Sends SMS to the phone number with the given message. The sending provides external program for sending sms. Its path is saved in the perun property perun.sms.program.- Parameters:
telNumber
- phone number of the receivermessage
- sms message to send- Throws:
InternalErrorException
- when there is something wrong with external programIllegalArgumentException
- when the phone or message has a wrong format
-
bigDecimalBytesToReadableStringWithMetric
Get BigDecimal number like '1024' in Bytes and create better readable String with metric value like '1K' where K means KiloBytes.Use M,G,T,P,E like multipliers of 1024.
If quota is not dividable by 1024 use B (Bytes) without dividing.
- Parameters:
quota
- in big natural number- Returns:
- string with number and metric
-
toASCII
Convert input string (expected UTF-8) to ASCII if possible. Any non-ASCII character is replaced by replacement parameter.- Parameters:
input
- String to convert from UTF-8 to ASCII.replacement
- Replacement character used for all non-ASCII chars in input.- Returns:
- converted string from ascii to something near utf
-
extendDateByPeriod
Extends given date by given period.- Parameters:
localDate
- date to be extendedperiod
- period used to extend date- Throws:
InternalErrorException
- when the period has wrong format, allowed format is given by regex "\\+([0-9]+)([dmy]?)"
-
shortenDateByPeriod
Shortens the given date by the given period.- Parameters:
localDate
- date to be shortenedperiod
- string of format ([0-9]+)([dmy])- Returns:
- shortened date
-
getClosestExpirationFromStaticDate
Returns closest future LocalDate based on values given by matcher. If returned value should fall to 29. 2. of non-leap year, the date is extended to 28. 2. instead.- Parameters:
matcher
- matcher with day and month values- Returns:
- Extended date.
-
prepareGracePeriodDate
Prepares grace period date by values from given matcher.- Parameters:
matcher
- matcher- Returns:
- pair of field(ChronoUnit.YEARS, ChronoUnit.MONTHS, ChronoUnit.DAYS) and amount
- Throws:
InternalErrorException
- when given matcher contains invalid dataIllegalArgumentException
- when matcher does not match gracePeriod format
-
escapeStringForLDAP
We need to escape some special characters for LDAP filtering. We need to escape these characters: '\\', '*', '(', ')', '\000'- Parameters:
searchString
- search string which need to be escaped properly- Returns:
- properly escaped search string
-
validateFullGroupName
-
validateGroupName
Validates given group name against a given regex.- Parameters:
name
- group nameregex
- regex to be used
-
validateGroupName
Validates group name.To check the group name, this method uses two regexes. A default one, hardcoded in the GroupsManager, and a secondary optional. The secondary regex can be default as a core property named groupNameSecondaryRegex.
- Parameters:
name
- name to be validated
-
validateSSHPublicKey
- Throws:
SSHKeyNotValidException
-
prepareSqlWhereForUserMemberSearch
public static String prepareSqlWhereForUserMemberSearch(String searchString, MapSqlParameterSource namedParams, boolean exactMatch) Returns a part of WHERE condition to search users and members in their ids, uuids, logins, ext sources user names and attributes by given search string.- Parameters:
searchString
- string to search bynamedParams
- parameters used in the queryexactMatch
- if true, searches user name only by exact match- Returns:
- search query
-
prepareUserSearchQueryExactMatch
Returns search query to search by user name (exact match) based on databased in use.- Returns:
- search query
-
prepareUserSearchQuerySimilarMatch
Returns search query to search by user name (similar match) based on databased in use.- Returns:
- search query
-
getDividedAttributes
Takes attributes from CoreConfig used in users or members search and divides them into correct categories based on attribute type (member, user, userExtSource).Then returns map: memberAttributes -> list of member attributes userAttributes -> list of user attributes uesAttributes -> list of userExtSource attributes
- Returns:
- map of attributes
-
prepareSqlWhereForGroupSearch
public static String prepareSqlWhereForGroupSearch(String searchString, MapSqlParameterSource namedParams, boolean subgroups) Returns a part of WHERE condition to search groups in their ids, uuids, names and descriptions by given search string.- Parameters:
searchString
- string to search bynamedParams
- parameters used in the querysubgroups
- if the WHERE condition should be prepared for parent group- Returns:
- search query
-
prepareSubgroupNameDscSearchQuerySimilarMatch
Returns search query to search by subgroup name or description (similar match) based on databased in use.- Returns:
- search query
-
prepareGroupNameDscSearchQuerySimilarMatch
Returns search query to search by group name or description (similar match) based on databased in use.- Returns:
- search query
-
prepareSqlWhereForApplicationsSearch
public static String prepareSqlWhereForApplicationsSearch(String searchString, MapSqlParameterSource namedParams) Returns a part of WHERE condition to search applications in their ids, username, group ids/uuids, names and description by given search string.- Parameters:
searchString
- string to search bynamedParams
- parameters used in the query- Returns:
- search query
-
prepareSqlWhereForInvitationSearch
public static String prepareSqlWhereForInvitationSearch(String searchString, MapSqlParameterSource namedParams) Returns a part of WHERE condition to search invitations in their ids, receiver's name and receiver's email by given search string.- Parameters:
searchString
- string to search bynamedParams
- parameters used in the query- Returns:
- search query
-
prepareGroupNameDscAppsSearchQuerySimilarMatch
Returns search query to search by group name or description (similar match) based on databased in use.- Returns:
- search query
-
prepareUsernameSearchQuerySimilarMatch
Returns search query to search by user name based on databased in use.- Returns:
- search query
-
prepareApplicationDataSearchQuerySimilarMatch
Returns search query to search by application's form data values based on databased in use.- Returns:
- search query
-
prepareReceiverNameEmailSearchQuerySimilarMatch
Returns search query to search by receiver name or email (similar match) based on databased in use.- Returns:
- search query
-
prepareSenderNameEmailSearchQuerySimilarMatch
Returns search query to search by sender name or email (similar match) based on databased in use.- Returns:
- search query
-
getAttributesQuery
public static Map<String,Pair<String, getAttributesQueryString>> (List<String> memberAttributes, List<String> userAttributes, List<String> uesAttributes) Prepares query to search users or members by attributes if received attribute list is not empty.Returns map: memberAttributesQueryString -> pair of parts of query to search by member attributes userAttributesQueryString -> pair of parts of query to search by user attributes uesAttributesQueryString -> pair of parts of query to search by userExtSource attributes
- Parameters:
memberAttributes
- member attributesuserAttributes
- user attributesuesAttributes
- userExtSource attributes- Returns:
- map of parts of query
-
getMapSqlParameterSourceToSearchUsersOrMembers
public static MapSqlParameterSource getMapSqlParameterSourceToSearchUsersOrMembers(String searchString, Map<String, List<String>> attributesToSearchBy) Returns MapSqlParameterSource with values added to search members or users.- Parameters:
searchString
- string used to search byattributesToSearchBy
- map of attributes used to search for users or members- Returns:
- filled MapSqlParameterSource
-
sendIdentityAddedAlerts
Sends all alerts about an identity being added. Sends an email to the preferred email of the user. Also, if the identity has an email and it is different that the preferred email, another different email is send to this email.- Parameters:
sess
- sessionnewUes
- removed userExtSource
-
sendIdentityRemovedAlerts
public static void sendIdentityRemovedAlerts(PerunSession sess, UserExtSource removedUes, List<Attribute> uesAttrs) Sends all alerts about an identity being removed. Sends an email to the preferred email of the user. Also, if the identity has an email and it is different that the preferred email, another different email is send to this email.- Parameters:
sess
- sessionremovedUes
- removed userExtSourceuesAttrs
- attributes of the removed userExtSource
-
isUserRelatedAttribute
Returns true if given attribute is user-related (it is user, user_facility, member, member_group, member_resource or ues attribute).- Parameters:
attribute
- the attribute- Returns:
- true if attribute is user-related
-
checkWordInSortedFile
public static boolean checkWordInSortedFile(String filename, String word) throws FileNotFoundException, IOException Performs binary search for EXACT match in SORTED ascii file. All entries need to be separated by newline and sorting needs to follow ASCII standard ('a' > 'A')!- Parameters:
filename
- path to sorted fileword
- word to be checked- Returns:
- true if word was found, false otherwise
- Throws:
FileNotFoundException
IOException
-