Class ExtSourceXML
java.lang.Object
cz.metacentrum.perun.core.api.PerunBean
cz.metacentrum.perun.core.api.Auditable
cz.metacentrum.perun.core.api.ExtSource
cz.metacentrum.perun.core.impl.ExtSourceImpl
cz.metacentrum.perun.core.impl.ExtSourceXML
- All Implemented Interfaces:
ExtSourceApi, ExtSourceSimpleApi, Serializable, Comparable<PerunBean>
- Direct Known Subclasses:
ExtSourceISXML
- Author:
- Michal Stava stavamichal@gmail.com
- See Also:
-
Field Summary
Fields inherited from class ExtSourceImpl
perunBl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()If extSource needs to be closed, this method must be called.convertNodeToMap(Node node) Get XML node and convert all values by "xmlMapping" attribute to Mapinvalid input: '<'String,String> In map there are "name=value" data.protected StringconvertToXpathSearchString(String query) Take plaintext query and create xpath query with concat function if needed.protected InputStreamGet https uri of xml document and create two way ssl connection using truststore and keystore.protected StringextractValueByRegex(String value, String regex) Get regex in format 'regex/replacement' and value to get data from.findSubjects(String searchString) Finds all subjects with attributes in the external source, that contains searchString.findSubjectsLogins(String searchString) Finds all subjects logins in the external source, that contains searchString.getCon()getGroupSubjects(Map<String, String> attributes) Get the list of the subjects in the external group.getSubjectByLogin(String login) Finds subject from the external source by the primary login used in external source.getSubjectGroups(Map<String, String> attributes) Get the list of the subject groups in the external source.Get the list of subjects from the external source.protected StringgetValueFromXpath(Node node, String xpathExpression) Get xml Node and xpath expression to get value from node by this xpath.protected voidvoidsetCon(HttpURLConnection con) xpathParsing(String query) Get query and maxResults.Methods inherited from class ExtSourceImpl
getAttributesMethods inherited from class ExtSource
compareTo, equals, getBeanName, getName, getType, hashCode, serializeToString, setName, setType, toStringMethods inherited from class Auditable
getCreatedAt, getCreatedBy, getCreatedByUid, getModifiedAt, getModifiedBy, getModifiedByUid, setCreatedAt, setCreatedBy, setCreatedByUid, setModifiedAt, setModifiedBy, setModifiedByUid
-
Constructor Details
-
ExtSourceXML
public ExtSourceXML()
-
-
Method Details
-
close
public void close()Description copied from interface:ExtSourceSimpleApiIf extSource needs to be closed, this method must be called.- Specified by:
closein interfaceExtSourceSimpleApi
-
convertNodeToMap
Get XML node and convert all values by "xmlMapping" attribute to Mapinvalid input: '<'String,String> In map there are "name=value" data.Attribute xmlMapping is from file perun-extSource.xml
- Parameters:
node- node for converting- Returns:
- Mapinvalid input: '<'String, String> like invalid input: '<'name,value>
- Throws:
InternalErrorException
-
convertToXpathSearchString
Take plaintext query and create xpath query with concat function if needed. IMPORTANT: especially if there are these characters: ' (single quote) and " (double quotes)- Parameters:
query- string for xpath query in plain text format- Returns:
- string for xpath, if there is needed, concat is used, if not, string without concet in quotes is returned, empty string if nothing in query
-
createTwoWaySSLConnection
Get https uri of xml document and create two way ssl connection using truststore and keystore.- Parameters:
uri- https uri to xml document- Returns:
- input stream with xml document
- Throws:
IOException- if there is some input/output errorInternalErrorException- if some variables are not correctly filled
-
extractValueByRegex
Get regex in format 'regex/replacement' and value to get data from. Use regex and replacement to get data from value.IMPORTANT: Regex must be always in format 'regex/replacement' and must have exactly 1 existence of character '/' ex. '[abc](a)[b]/$1'
- Parameters:
value- some stringregex- regex in format 'regex/replacement'- Returns:
- extracted string from value by regex
- Throws:
InternalErrorException
-
findSubjects
Description copied from interface:ExtSourceApiFinds all subjects with attributes in the external source, that contains searchString.This method is used for getting all logins of subjects in external source with all possible attributes.
- Specified by:
findSubjectsin interfaceExtSourceApi- Parameters:
searchString-- Returns:
- list of maps, which contains attr_name->attr_value (for all extSource attributes)
-
findSubjectsLogins
public List<Map<String,String>> findSubjectsLogins(String searchString) throws ExtSourceUnsupportedOperationException Description copied from interface:ExtSourceSimpleApiFinds all subjects logins in the external source, that contains searchString.This method is used for getting all logins of subjects in external source and then use them to searching in external source for other subjects attributes.
- Specified by:
findSubjectsLoginsin interfaceExtSourceSimpleApi- Parameters:
searchString-- Returns:
- list of maps, which contains attr_name->attr_value but only for login definition eg. login;MichalS
- Throws:
ExtSourceUnsupportedOperationException
-
getCon
-
getGroupSubjects
Description copied from interface:ExtSourceSimpleApiGet the list of the subjects in the external group.- Specified by:
getGroupSubjectsin interfaceExtSourceSimpleApi- Parameters:
attributes- map of attributes used for quering the external source- Returns:
- list of maps, which contains attr_name->attr_value, e.g. firstName->Michal
-
getSubjectByLogin
Description copied from interface:ExtSourceSimpleApiFinds subject from the external source by the primary login used in external source.- Specified by:
getSubjectByLoginin interfaceExtSourceSimpleApi- Parameters:
login- login used in the external source- Returns:
- map which contains attr_name -> attr_value, e.g. firstName->Michal
- Throws:
SubjectNotExistsException- if the subject cannot be found
-
getSubjectGroups
public List<Map<String,String>> getSubjectGroups(Map<String, String> attributes) throws ExtSourceUnsupportedOperationExceptionDescription copied from interface:ExtSourceSimpleApiGet the list of the subject groups in the external source.- Specified by:
getSubjectGroupsin interfaceExtSourceSimpleApi- Parameters:
attributes- map of attributes used for quering the external source- Returns:
- list of maps, which contains attr name and attr value
- Throws:
ExtSourceUnsupportedOperationException
-
getUsersSubjects
Description copied from interface:ExtSourceSimpleApiGet the list of subjects from the external source.- Specified by:
getUsersSubjectsin interfaceExtSourceSimpleApi- Returns:
- list of maps, which contains attr_name->attr_value, e.g. firstName->Michal
-
getValueFromXpath
Get xml Node and xpath expression to get value from node by this xpath.- Parameters:
node- node for getting value fromxpathExpression- expression for xpath to looking for value in node- Returns:
- string extracted from node by xpath
- Throws:
InternalErrorException
-
prepareEnvironment
protected void prepareEnvironment() -
setCon
-
xpathParsing
Get query and maxResults. Prepare document and xpathExpression by query. Get all nodes by xpath from document and parse them one by one.The way of xml take from "file" or "uri" (configuration file)
- Parameters:
query- xpath query from config file- Returns:
- List of results, where result is Mapinvalid input: '<'String,String> like invalid input: '<'name, value>
- Throws:
InternalErrorException
-