Class GrouperClientUtils
java.lang.Object
edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
edu.internet2.middleware.grouperClient.util.GrouperClientUtils
utility methods specific to grouper client
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classdont print null fields in reflectionNested classes/interfaces inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
GrouperClientCommonUtils.CommandResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringuse this for performance log label for sql queriesFields inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
DATE_FORMAT, DATE_MINUTES_SECONDS_FORMAT, DATE_MINUTES_SECONDS_NO_SLASH_FORMAT, DEFAULT_BUFFER_SIZE, EMPTY, EMPTY_OBJECT_ARRAY, EMPTY_STRING_ARRAY, INDEX_NOT_FOUND, LOG_ERROR, NOT_FOUND, ONE_GB, ONE_KB, ONE_MB, TIMESTAMP_DASHES_TENTHS_FORMAT, TIMESTAMP_FILE_FORMAT, TIMESTAMP_FORMAT, TIMESTAMP_NO_SLASH_FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringappendQuestions(int numberOfMarks) append a certain number of question marks to a querystatic voidappendQuestions(StringBuilder query, int numberOfMarks) append a certain number of question marks to a querystatic Stringname of the cache directory without trailing slashstatic StringdecryptFromFileIfFileExists(String pass, StringBuilder logInfo) decrypt a pass from a file if the file exists (i.e. passes might have slashes in them)static Stringstatic StringencryptSha(String plaintext) encrypt a message to SHA with base 64static StringextensionFromName(String name) get the extension from name.Deprecated.use GrouperClientConfig.retrieveConfig().propertiesOverrideMap() insteadstatic PropertiesDeprecated.use GrouperClientConfig.retrieveConfig().properties() insteadstatic StringhttpBasicAuthenticationString(String login, String password) Create a basic authentication string.static HttpCallResponsehttpCall(String urlSuffix, String serviceAuthn, HttpCallMethod httpCallMethod, String body) call HTTP with a url, optional request body, get a response body.static org.apache.http.impl.client.CloseableHttpClienthttpClient(boolean reuseIfConfigured) static voidhttpCloseQuietly(org.apache.http.impl.client.CloseableHttpClient closeableHttpClient, org.apache.http.client.methods.HttpRequestBase httpRequestBase, org.apache.http.client.methods.CloseableHttpResponse closeableHttpResponse, boolean reuseIfConfigured) static org.apache.http.impl.client.CloseableHttpClienthttpTrustAllClient(boolean reuseIfConfigured) static voidwait for a thread to endstatic ObjectjsonConvertFrom(Map<String, Class<?>> conversionMap, String json) convert an object from json.static StringjsonConvertTo(Object object, boolean includeObjectNameWrapper) convert object to json, optionally include object name wrapperstatic voidstatic voidperformanceTimingAllDuration(String key, long durationNanos) static StringpopUrlString(List<String> urlStrings) pop first url string, retrieve, and remove, or null if not therestatic StringpropertiesValue(String key, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueString insteadstatic booleanpropertiesValueBoolean(String key, boolean defaultValue, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueBoolean insteadstatic intpropertiesValueInt(String key, int defaultValue, boolean required) Deprecated.GrouperClientConfig.retrieveConfig().propertyValueIntstatic org.apache.commons.logging.LogretrieveLog(Class<?> theClass) static StringsubjectAttributeValue(WsSubject wsSubject, String[] attributeNames, String attributeName) get the attribute value of an attribute name of a subjectstatic StringsubstituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap) substitute an EL for objects.static StringsubstituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap, boolean allowStaticClasses, boolean silent, boolean lenient, boolean logOnNull) substitute an EL for objectsstatic StringtoStringReflection(Object object) to string reflectionstatic StringtoStringReflection(Object object, Set<String> fieldsToIgnore) to string reflectionstatic StringtoStringReflection(Object object, Set<String> fieldsToIgnore, String extraInfo) to string reflectionMethods inherited from class edu.internet2.middleware.grouperClient.util.GrouperClientCommonUtils
abbreviate, abbreviate, absolutePath, addIfNotThere, append, appendIfNotBlank, appendIfNotBlank, appendIfNotBlank, appendIfNotBlank, appendIfNotBlankString, appendIfNotEmpty, appendIfNotEmpty, appendIfNotEmpty, appendIfNotEmpty, argAfter, argKey, argMap, argMapBoolean, argMapBoolean, argMapFileList, argMapInteger, argMapList, argMapSet, argMapString, argMapTimestamp, argValue, arrayPopOne, assertion, assignField, assignField, assignField, assignField, assignField, assignSetter, batchList, batchNumberOfBatches, batchNumberOfBatches, batchNumberOfBatches, batchNumberOfBatches, bigDecimalObjectValue, booleanObjectValue, booleanValue, booleanValue, byteCountToDisplaySize, byteObjectValue, byteValue, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, capitalize, charObjectValue, charValue, classesString, classLoader, className, classNameCollection, clone, cloneFields, cloneValue, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, closeQuietly, collectionPopOne, collectionToString, compare, compareObjectFields, computeUrl, construct, contains, contains, contains, convertLongToChar, convertLongToCharSmall, convertLongToString, convertLongToStringSmall, convertMillisToFriendlyString, convertMillisToFriendlyString, convertToRuntimeException, convertUrlToDriverClassIfNeeded, copy, copy, copy, copy, copy, copyLarge, createParentDirectories, createRuntimeExceptionWithMessage, dateLongValue, dateStringValue, dateStringValue, dateToString, dateValue, debugMapIncrementLogEntry, defaultIfBlank, defaultIfEmpty, defaultIfNull, defaultString, defaultString, deleteCreateFile, deleteFile, deleteRecursiveDirectory, doubleObjectValue, doubleObjectValue, doubleValue, doubleValueNoError, endsWith, enumValueOfIgnoreCase, environmentVariable, equals, equals, equalsIgnoreCase, escapeUrlDecode, escapeUrlEncode, execCommand, execCommand, execCommand, field, fieldNames, fieldNames, fieldNames, fieldNames, fields, fields, fieldValue, fieldValue, fieldValue, fieldValue, fileCanonicalPath, fileFromResourceName, fileOrClasspathInputstream, floatObjectValue, floatValue, floatValueNoError, formatNumberWithCommas, forName, get, getCause, getCause, getFullStackTrace, getMaxLongValue, getMinLongValue, getter, getterHelper, getterNameFromPropertyName, getters, getThrowables, grouperClientVersion, grouperWsVersionConvert, hasOption, hostname, incrementChar, incrementStringInt, indent, indexOf, indexOf, injectInException, intObjectValue, intValue, intValue, intValueNoError, invokeMethod, invokeMethod, ipInt, ipOnNetwork, ipOnNetworks, ipReadyForAnd, isAscii, isBlank, isBlank, isEmpty, iserNameFromPropertyName, isGetter, isMysql, isNestedThrowable, isNotBlank, isOracle, isPostgres, isScalar, isSetter, isSQLServer, isThrowableNested, isWindows, iterator, jarFile, jarFile, jarVersion, join, join, join, join, join, leftPad, leftPad, leftPad, length, lengthAscii, listPopOne, longObjectValue, longValue, longValue, longValueNoError, manifestProperty, mapAddValue, mapAddValue, mapDifferences, mapEquals, mapToString, MapToString, method, methodNames, methodsHelper, mkdirs, monthInt, newFileUniqueName, newInstance, newInstance, next, nonNull, nonNull, nonNull, nonNull, nonNull, normalizeEmailAddresses, nullOrBlank, oracleStandardNameFromJava, packInts, parentStemNameFromName, prefixOrSuffix, processEnvVarOrFile, processEnvVarOrFileNoTrim, propertiesCacheClear, propertiesFromFile, propertiesFromResourceName, propertiesFromResourceName, propertiesThreadLocalOverrideMap, propertiesValue, propertiesValue, propertiesValue, propertiesValue, propertiesValueBoolean, propertiesValueBoolean, propertiesValueBoolean, propertiesValueBoolean, propertiesValueInt, propertiesValueInt, propertiesValueInt, propertyName, propertyType, propertyValidateValueBoolean, propertyValidateValueClass, propertyValidateValueInt, propertyValidateValueRequired, propertyValue, readFileIntoString, readFileIntoStringUtf8, readFileIntoStringUtf8, readFileIntoStringUtf8, readFileToString, readFromFileIfFile, readFromFileIfFileExists, readFromFileIfFileUtf8, readResourceIntoString, readResourceIntoString, remove, remove, removeEnd, removeEnd, renameTo, repeat, replace, replace, replace, replace, replace, replace, replace, replace, replace, replaceWhitespaceWithSpace, responseBodyAsString, retrieveExecutorService, retrievePasswordFromStdin, retrievePasswordFromStdin, rightPad, rightPad, rightPad, rollbackQuietly, saveStringIntoFile, saveStringIntoFile, serializeObjectToFile, setPopOne, setShorten, setter, setterHelper, setterNameFromPropertyName, setters, setToString, shortObjectValue, shortValue, sleep, sleepWithStdoutCountdown, split, split, split, split, splitByWholeSeparator, splitByWholeSeparator, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitTrim, splitTrim, splitTrimToList, splitTrimToSet, stack, stringLength, stringToDate, stringToDate2, stringToTimestamp, stringValue, stringValue, stripEnd, stripLastSlashIfExists, stripPrefix, stripStart, stripSuffix, substituteCommonVars, substringAfter, substringAfterLast, substringBefore, substringBeforeLast, suffixAfterChar, timestampToFileString, timestampToString, toArray, toArray, toList, toListClasses, toListFromCollection, toListObject, toMap, toSet, toSetObject, toSqlDate, toString, toString, toStringForLog, toStringForLog, toStringForLog, toStringObjectMap, toStringSafe, toTimestamp, trim, trimToEmpty, truncateAscii, typeCast, typeCast, uniqueId, unpackInt, unserializeObjectFromFile, uuid, validEmail, writeStringToFile, xmlEscape
-
Field Details
-
PERFORMANCE_LOG_LABEL_SQL
use this for performance log label for sql queries- See Also:
-
-
Constructor Details
-
GrouperClientUtils
public GrouperClientUtils()
-
-
Method Details
-
httpTrustAllClient
public static org.apache.http.impl.client.CloseableHttpClient httpTrustAllClient(boolean reuseIfConfigured) -
httpClient
public static org.apache.http.impl.client.CloseableHttpClient httpClient(boolean reuseIfConfigured) -
httpBasicAuthenticationString
Create a basic authentication string.- Parameters:
login- is the login.password- is the password.- Returns:
- "Basic login:password" where login:password is Base64 encoded.
-
httpCloseQuietly
public static void httpCloseQuietly(org.apache.http.impl.client.CloseableHttpClient closeableHttpClient, org.apache.http.client.methods.HttpRequestBase httpRequestBase, org.apache.http.client.methods.CloseableHttpResponse closeableHttpResponse, boolean reuseIfConfigured) -
main
- Throws:
Exception
-
extensionFromName
get the extension from name. if name is a:b:c, name is c- Parameters:
name-- Returns:
- the name
-
jsonConvertTo
convert object to json, optionally include object name wrapper- Parameters:
object-includeObjectNameWrapper-- Returns:
- the json
-
jsonConvertFrom
convert an object from json. note this works well if there are no collections, just real types, arrays, etc.- Parameters:
conversionMap- is the class simple name to class of objects which are allowed to be brought back. Note: only the top level object needs to be registeredjson-- Returns:
- the object
-
performanceTimingAllDuration
- Parameters:
key-durationNanos-
-
toStringReflection
to string reflection- Parameters:
object-- Returns:
- the string representation
-
toStringReflection
public static String toStringReflection(Object object, Set<String> fieldsToIgnore, String extraInfo) to string reflection- Parameters:
object-- Returns:
- the string representation
-
toStringReflection
to string reflection- Parameters:
object-- Returns:
- the string representation
-
appendQuestions
append a certain number of question marks to a query- Parameters:
query-numberOfMarks-
-
appendQuestions
append a certain number of question marks to a query- Parameters:
query-numberOfMarks-
-
retrieveLog
- Parameters:
theClass-- Returns:
- the log
-
grouperClientOverrideMap
Deprecated.use GrouperClientConfig.retrieveConfig().propertiesOverrideMap() insteadoverride map for properties for testing- Returns:
- the override map
-
grouperClientProperties
Deprecated.use GrouperClientConfig.retrieveConfig().properties() insteadgrouper client properties- Returns:
- the properties
-
propertiesValue
Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueString insteadget a property and validate required from grouper.client.properties- Parameters:
key-required-- Returns:
- the value
-
propertiesValueBoolean
@Deprecated public static boolean propertiesValueBoolean(String key, boolean defaultValue, boolean required) Deprecated.use GrouperClientConfig.retrieveConfig().propertyValueBoolean insteadget a boolean and validate from grouper.client.properties- Parameters:
key-defaultValue-required-- Returns:
- the string
-
propertiesValueInt
Deprecated.GrouperClientConfig.retrieveConfig().propertyValueIntget a boolean and validate from grouper.client.properties- Parameters:
key-defaultValue-required-- Returns:
- the string
-
substituteExpressionLanguage
public static String substituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap) substitute an EL for objects. Dont worry if something returns null- Parameters:
stringToParse-variableMap-- Returns:
- the string
-
join
wait for a thread to end- Parameters:
thread-
-
substituteExpressionLanguage
public static String substituteExpressionLanguage(String stringToParse, Map<String, Object> variableMap, boolean allowStaticClasses, boolean silent, boolean lenient, boolean logOnNull) substitute an EL for objects- Parameters:
stringToParse-variableMap-allowStaticClasses- if true allow static classes not registered with contextsilent- if silent mode, swallow exceptions (warn), and dont warn when variable not foundlenient- false if undefined variables should throw an exception. if lenient is true (default) then undefined variables are nulllogOnNull- if null output of substitution should be logged- Returns:
- the string
-
subjectAttributeValue
public static String subjectAttributeValue(WsSubject wsSubject, String[] attributeNames, String attributeName) get the attribute value of an attribute name of a subject- Parameters:
wsSubject- subjectattributeNames- list of attribute names in the subjectattributeName- to query- Returns:
- the value or null
-
encryptKey
- Returns:
- the encrypt key
-
decryptFromFileIfFileExists
decrypt a pass from a file if the file exists (i.e. passes might have slashes in them)- Parameters:
pass-logInfo- if not null, put log info in there- Returns:
- the pass
-
cacheDirectoryName
name of the cache directory without trailing slash- Returns:
- the name of the cache directory
-
encryptSha
encrypt a message to SHA with base 64- Parameters:
plaintext-- Returns:
- the hash
-
httpCall
public static HttpCallResponse httpCall(String urlSuffix, String serviceAuthn, HttpCallMethod httpCallMethod, String body) call HTTP with a url, optional request body, get a response body. this assumes json by default- Parameters:
urlSuffix- is after the configured URL, or if it starts with http:// or https:// just use thatserviceAuthn- is the config string that identifies the user/pass/urlhttpCallMethod- HTTPbody- to send if applicable- Returns:
- the response
-
popUrlString
pop first url string, retrieve, and remove, or null if not there- Parameters:
urlStrings-- Returns:
- the string or null if not there
-