List of usage examples for org.apache.commons.httpclient HttpClient getHttpConnectionManager
public HttpConnectionManager getHttpConnectionManager()
From source file:org.geefive.salesforce.soqleditor.RESTfulQuery.java
public void executeQuery() throws Exception { Vector soqlResults = new Vector(); HttpClient restClient = new HttpClient(); restClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109); restClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); // String restfulURLTarget = serverDomain + REST_LOGIN; String restfulURLTarget = serverDomain + REST_QUERY; System.out.println("RESTful URL Target: " + restfulURLTarget); GetMethod method = null;/*w w w.ja v a 2s . c o m*/ try { method = new GetMethod(restfulURLTarget); System.out.println("Setting authorization header with SID [" + SID + "]"); method.setRequestHeader("Authorization", "OAuth " + SID); NameValuePair[] params = new NameValuePair[1]; params[0] = new NameValuePair("q", "SELECT Name, Id, Phone, CreatedById from Account LIMIT 100"); method.setQueryString(params); int httpResponseCode = restClient.executeMethod(method); System.out.println("HTTP_RESPONSE_CODE [" + httpResponseCode + "]"); System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); System.out .println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTING QUERY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); if (httpResponseCode == HttpStatus.SC_OK) { try { JSONObject response = new JSONObject( new JSONTokener(new InputStreamReader(method.getResponseBodyAsStream()))); System.out.println("_____________________________________"); System.out.println("RESPONSE [" + response + "]"); // Iterator itr = response.keys(); // while(itr.hasNext()){ // String key = (String)itr.next(); // System.out.println("KEY: " + (String)itr.next()); // } JSONArray resultArray = response.getJSONArray("records"); StringBuffer soqlQueryResults = new StringBuffer(); String token = ""; JSONObject inner = null; System.out.println(resultArray.getString(0)); inner = resultArray.getJSONObject(0); Iterator keys = inner.keys(); HashMap columnNames = new HashMap(); while (keys.hasNext()) { String column = (String) keys.next(); System.out.println("KEY>> " + column); columnNames.put(column, ""); soqlQueryResults.append(token + column); token = " * "; } soqlResults.add(soqlQueryResults.toString()); //System.out.println("******* UNCOMMENT ME FOR RELEASE *******"); Iterator keyset = null; JSONArray results = response.getJSONArray("records"); for (int i = 0; i < results.length(); i++) { soqlQueryResults.setLength(0); keyset = columnNames.keySet().iterator(); token = ""; while (keyset.hasNext()) { String columnName = (String) keyset.next(); if (!columnName.equalsIgnoreCase("attributes")) { soqlQueryResults.append(token + results.getJSONObject(i).getString(columnName)); token = " * "; } } // System.out.println("=====>>>>>>> " + soqlQueryResults.toString()); soqlResults.add(soqlQueryResults.toString()); // System.out.println(results.getJSONObject(i).getString("Id") + ", " // + results.getJSONObject(i).getString("Name") + ", " // + results.getJSONObject(i).getString("Phone") // + ", " + results.getJSONObject(i).getString("CreatedById")); } //end for } catch (JSONException jsonex) { throw jsonex; } } } finally { method.releaseConnection(); } Iterator finalData = soqlResults.iterator(); while (finalData.hasNext()) { System.out.println("-||=========>> " + (String) finalData.next()); } System.out.println("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXIT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); }
From source file:org.geefive.salesforce.soqleditor.SObjectDataLoader.java
public void executeObjectSearch() throws Exception { HttpClient restClient = new HttpClient(); restClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109); restClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); String restfulURLTarget = sfdcOauth.getServerURL() + sfdcOauth.getSobjectURI(); GetMethod method = null;//from w w w . j a va 2 s. co m try { method = new GetMethod(restfulURLTarget); method.setRequestHeader("Authorization", "OAuth " + sfdcOauth.getSecureID()); int httpResponseCode = restClient.executeMethod(method); System.out.println("HTTP_RESPONSE_CODE [" + httpResponseCode + "]"); if (httpResponseCode == HttpStatus.SC_OK) { JSONObject response = new JSONObject( new JSONTokener(new InputStreamReader(method.getResponseBodyAsStream()))); // JSONArray resultArray = response.getJSONArray("sobjects"); // JSONObject inner = null; // inner = resultArray.getJSONObject(0); // Iterator keys = inner.keys(); // HashMap columnNames = new HashMap(); // while(keys.hasNext()){ // String column = (String)keys.next(); // if(!column.equalsIgnoreCase("attributes")){ // columnNames.put(column, ""); // } // } JSONArray results = response.getJSONArray("sobjects"); reference.setMaxValue(results.length()); String objectName = null; for (int objID = 0; objID < results.length(); objID++) { try { if (results.getJSONObject(objID).getString("searchable").equals("true")) { objectName = results.getJSONObject(objID).getString("name"); // if(objectName.equals("userchild__c")){ sObjects.add(parseObjectDetails(new SObjectItem(objectName))); // } reference.updateProgressBar(objectName, objID); if (objectName.endsWith("__c")) { reference.incrementCustomObject(); } else { reference.incrementStandardObject(); } } //end if-else } catch (NullPointerException ex) { ex.printStackTrace(); } } //end for } //end success } finally { method.releaseConnection(); } // return sObjects; }
From source file:org.geefive.salesforce.soqleditor.SObjectDataLoader.java
private SObjectItem parseObjectDetails(SObjectItem objectField) throws Exception { //System.out.println("xxxxxxxxxxxxxxxxxxxxx " + objectField.getObjectName() + " xxxxxxxxxxxxxxxxxxxxx"); HttpClient restClient = new HttpClient(); restClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109); restClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); String restfulURLTarget = sfdcOauth.getServerURL() + sfdcOauth.getSobjectURI() + "/" + objectField.getObjectName() + "/describe/"; // System.out.println("RESTful URL Target: " + restfulURLTarget); GetMethod method = null;/*from w w w . j a v a 2 s .c o m*/ try { method = new GetMethod(restfulURLTarget); method.setRequestHeader("Authorization", "OAuth " + sfdcOauth.getSecureID()); int httpResponseCode = restClient.executeMethod(method); // System.out.println("HTTP_RESPONSE_CODE [" + httpResponseCode + "]"); if (httpResponseCode == HttpStatus.SC_OK) { JSONObject response = new JSONObject( new JSONTokener(new InputStreamReader(method.getResponseBodyAsStream()))); // System.out.println("RESPONSE [" + response + "]"); JSONArray fieldObject = response.getJSONArray("fields"); try { SObjectColumnDetail object = null; for (int row = 0; row < fieldObject.length(); row++) { object = new SObjectColumnDetail(); // System.out.println("name [" + fieldObject.getJSONObject(row).getString("name") + "]"); object.setFieldName(fieldObject.getJSONObject(row).getString("name")); // System.out.println("length [" + fieldObject.getJSONObject(row).getString("length") + "]"); object.setLength(fieldObject.getJSONObject(row).getString("length")); // System.out.println("digits [" + fieldObject.getJSONObject(row).getString("digits") + "]"); object.setDigits(fieldObject.getJSONObject(row).getString("digits")); // System.out.println("defaultValue [" + fieldObject.getJSONObject(row).getString("defaultValue") + "]"); object.setDefaultValue(fieldObject.getJSONObject(row).getString("defaultValue")); // System.out.println("autoNumber [" + fieldObject.getJSONObject(row).getString("autoNumber") + "]"); object.setAutoNumber(fieldObject.getJSONObject(row).getString("autoNumber")); // System.out.println("calculated [" + fieldObject.getJSONObject(row).getString("calculated") + "]"); object.setCalculated(fieldObject.getJSONObject(row).getString("calculated")); if (fieldObject.getJSONObject(row).getString("calculated").equals("true")) { // System.out.println("calculatedFormula [" + fieldObject.getJSONObject(row).getString("calculatedFormula") + "]"); object.setCalculatedFormula( fieldObject.getJSONObject(row).getString("calculatedFormula")); } objectField.addColumnDetail(object); // System.out.println("..............."); } } catch (Exception ex) { ex.printStackTrace(); } } } finally { method.releaseConnection(); } // System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); return objectField; }
From source file:org.geefive.salesforce.soqleditor.SOQLQueryEngine.java
public QueryResultContainer executeQuery(String soql) throws Exception { HttpClient restClient = new HttpClient(); restClient.getParams().setCookiePolicy(CookiePolicy.RFC_2109); restClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000); String restfulURLTarget = sfdcOauth.getServerURL() + sfdcOauth.getQueryURI(); GetMethod method = null;/*from w w w . ja va2 s. c om*/ QueryResultContainer soqlResults = new QueryResultContainer(); try { method = new GetMethod(restfulURLTarget); // updateStatus("Setting authorization header with SID [" + sfdcOauth.getSecureID() + "]"); method.setRequestHeader("Authorization", "OAuth " + sfdcOauth.getSecureID()); NameValuePair[] params = new NameValuePair[1]; // params[0] = new NameValuePair("q","SELECT Name, Id, Phone, CreatedById from Account LIMIT 100"); params[0] = new NameValuePair("q", soql); method.setQueryString(params); int httpResponseCode = restClient.executeMethod(method); // updateStatus("HTTP_RESPONSE_CODE [" + httpResponseCode + "]"); // updateStatus("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); // updateStatus("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EXECUTING QUERY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"); if (httpResponseCode == HttpStatus.SC_OK) { try { JSONObject response = new JSONObject( new JSONTokener(new InputStreamReader(method.getResponseBodyAsStream()))); JSONArray results = response.getJSONArray("records"); Vector<HashMap<String, String>> resies = getResults(results, new HashMap<String, String>(), new Vector<HashMap<String, String>>(), ""); soqlResults = createOutput(resies); } catch (JSONException jsonex) { throw jsonex; } } } finally { method.releaseConnection(); } return soqlResults; }
From source file:org.geosdi.geoplatform.publish.HttpUtilsLocal.java
/** * Performs an HTTP GET on the given URL. * <BR>Basic auth is used if both username and pw are not null. * * @param url The URL where to connect to. * @param username Basic auth credential. No basic auth if null. * @param pw Basic auth credential. No basic auth if null. * @return The HTTP response as a String if the HTTP response code was 200 (OK). * @throws MalformedURLException/*w ww .j a v a 2 s. c o m*/ */ public static String get(String url, String username, String pw) throws MalformedURLException { GetMethod httpMethod = null; try { HttpClient client = new HttpClient(); setAuth(client, url, username, pw); httpMethod = new GetMethod(url); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(httpMethod); if (status == HttpStatus.SC_OK) { InputStream is = httpMethod.getResponseBodyAsStream(); String response = IOUtils.toString(is); if (response.trim().length() == 0) { // sometime gs rest fails LOGGER.warn("ResponseBody is empty"); return null; } else { return response; } } else { LOGGER.info("(" + status + ") " + HttpStatus.getStatusText(status) + " -- " + url); } } catch (ConnectException e) { LOGGER.info("Couldn't connect to [" + url + "]"); } catch (IOException e) { LOGGER.info("Error talking to [" + url + "]", e); } finally { if (httpMethod != null) { httpMethod.releaseConnection(); } } return null; }
From source file:org.geosdi.geoplatform.publish.HttpUtilsLocal.java
/** * Send an HTTP request (PUT or POST) to a server. * <BR>Basic auth is used if both username and pw are not null. * <P>/* www . java 2 s . co m*/ * Only <UL> * <LI>200: OK</LI> * <LI>201: ACCEPTED</LI> * <LI>202: CREATED</LI> * </UL> are accepted as successful codes; in these cases the response string will be returned. * * @return the HTTP response or <TT>null</TT> on errors. */ private static String send(final EntityEnclosingMethod httpMethod, String url, RequestEntity requestEntity, String username, String pw) { try { HttpClient client = new HttpClient(); setAuth(client, url, username, pw); // httpMethod = new PutMethod(url); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); if (requestEntity != null) { httpMethod.setRequestEntity(requestEntity); } int status = client.executeMethod(httpMethod); switch (status) { case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_CREATED: case HttpURLConnection.HTTP_ACCEPTED: String response = IOUtils.toString(httpMethod.getResponseBodyAsStream()); // LOGGER.info("================= POST " + url); LOGGER.info("HTTP " + httpMethod.getStatusText() + ": " + response); return response; default: LOGGER.warn("Bad response: code[" + status + "]" + " msg[" + httpMethod.getStatusText() + "]" + " url[" + url + "]" + " method[" + httpMethod.getClass().getSimpleName() + "]: " + IOUtils.toString(httpMethod.getResponseBodyAsStream())); return null; } } catch (ConnectException e) { LOGGER.info("Couldn't connect to [" + url + "]"); return null; } catch (IOException e) { LOGGER.error("Error talking to " + url + " : " + e.getLocalizedMessage()); return null; } finally { if (httpMethod != null) { httpMethod.releaseConnection(); } } }
From source file:org.geosdi.geoplatform.publish.HttpUtilsLocal.java
public static boolean delete(String url, final String user, final String pw) { DeleteMethod httpMethod = null;//from w w w . ja va2 s. c om try { HttpClient client = new HttpClient(); setAuth(client, url, user, pw); httpMethod = new DeleteMethod(url); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); int status = client.executeMethod(httpMethod); String response = ""; if (status == HttpStatus.SC_OK) { InputStream is = httpMethod.getResponseBodyAsStream(); response = IOUtils.toString(is); if (response.trim().equals("")) { // sometimes gs rest fails if (LOGGER.isDebugEnabled()) { LOGGER.debug( "ResponseBody is empty (this may be not an error since we just performed a DELETE call)"); } return true; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("(" + status + ") " + httpMethod.getStatusText() + " -- " + url); } return true; } else { LOGGER.info("(" + status + ") " + httpMethod.getStatusText() + " -- " + url); LOGGER.info("Response: '" + response + "'"); } } catch (ConnectException e) { LOGGER.info("Couldn't connect to [" + url + "]"); } catch (IOException e) { LOGGER.info("Error talking to [" + url + "]", e); } finally { if (httpMethod != null) { httpMethod.releaseConnection(); } } return false; }
From source file:org.geosdi.geoplatform.publish.HttpUtilsLocal.java
public static boolean httpPing(String url, String username, String pw) { GetMethod httpMethod = null;//from w w w . j ava2 s . c o m try { HttpClient client = new HttpClient(); setAuth(client, url, username, pw); httpMethod = new GetMethod(url); client.getHttpConnectionManager().getParams().setConnectionTimeout(2000); int status = client.executeMethod(httpMethod); if (status != HttpStatus.SC_OK) { LOGGER.warn("PING failed at '" + url + "': (" + status + ") " + httpMethod.getStatusText()); return false; } else { return true; } } catch (ConnectException e) { return false; } catch (IOException e) { e.printStackTrace(); return false; } finally { if (httpMethod != null) { httpMethod.releaseConnection(); } } }
From source file:org.geosdi.geoplatform.publish.HttpUtilsLocal.java
/** * Used to query for REST resources.//from w w w. jav a2s .c o m * * @param url The URL of the REST resource to query about. * @param username * @param pw * @return true on 200, false on 404. * @throws RuntimeException on unhandled status or exceptions. */ public static boolean exists(String url, String username, String pw) { GetMethod httpMethod = null; try { HttpClient client = new HttpClient(); setAuth(client, url, username, pw); httpMethod = new GetMethod(url); client.getHttpConnectionManager().getParams().setConnectionTimeout(2000); int status = client.executeMethod(httpMethod); switch (status) { case HttpStatus.SC_OK: return true; case HttpStatus.SC_NOT_FOUND: return false; default: throw new RuntimeException("Unhandled response status at '" + url + "': (" + status + ") " + httpMethod.getStatusText()); } } catch (ConnectException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } finally { if (httpMethod != null) { httpMethod.releaseConnection(); } } }
From source file:org.geoserver.security.onelogin.OneloginAuthenticationFilter.java
/** * Configures {@link MetadataGenerator} using EntityId and ID MetadataURL from filter configuration<br/> * Configures SAMLUserDetailsService to use {@link GeoServerRole} selected provider */// ww w .j a va2 s . c o m @Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); OneloginAuthenticationFilterConfig authConfig = (OneloginAuthenticationFilterConfig) config; try { if (getNestedFilters().isEmpty()) { /* * Create metadata filter */ MetadataGenerator generator = new MetadataGenerator(); generator.setEntityId(authConfig.getEntityId()); generator.setIncludeDiscoveryExtension(false); generator.setKeyManager(new EmptyKeyManager()); generator.setRequestSigned(false); generator.setWantAssertionSigned(authConfig.getWantAssertionSigned()); ExtendedMetadata em = new ExtendedMetadata(); em.setRequireLogoutRequestSigned(false); generator.setExtendedMetadata(em); MetadataGeneratorFilter metadataGeneratorFilter = new MetadataGeneratorFilter(generator); /* * Create metadata provider */ ParserPool parserPool = context.getBean(ParserPool.class); HttpClientParams clientParams = new HttpClientParams(); clientParams.setSoTimeout(5000); HttpClient httpClient = new HttpClient(clientParams); httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(5000); HTTPMetadataProvider pro = new HTTPMetadataProvider(new Timer(true), httpClient, authConfig.getMetadataURL()); pro.setParserPool(parserPool); /* * Use this to pass metadata string String xml = * "<?xml version=\"1.0\"?> <EntityDescriptor xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"https://app.onelogin.com/saml/metadata/575443\"> <IDPSSODescriptor xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"> <KeyDescriptor use=\"signing\"> <ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\"> <ds:X509Data> <ds:X509Certificate>MIIEHTCCAwWgAwIBAgIUIYlArFxWB1C7BX6q/mFytCIYeI8wDQYJKoZIhvcNAQEF BQAwWjELMAkGA1UEBhMCVVMxEzARBgNVBAoMCmNvZGVzdHVkaW8xFTATBgNVBAsM DE9uZUxvZ2luIElkUDEfMB0GA1UEAwwWT25lTG9naW4gQWNjb3VudCA4ODk4ODAe Fw0xNjA4MDMxMDUyNTNaFw0yMTA4MDQxMDUyNTNaMFoxCzAJBgNVBAYTAlVTMRMw EQYDVQQKDApjb2Rlc3R1ZGlvMRUwEwYDVQQLDAxPbmVMb2dpbiBJZFAxHzAdBgNV BAMMFk9uZUxvZ2luIEFjY291bnQgODg5ODgwggEiMA0GCSqGSIb3DQEBAQUAA4IB DwAwggEKAoIBAQDWKHu+QvLa9BvqL6OoKKMVMBY0deHU6xqPAoatxiGlNIazoK8T PY5srjRX18W4aOb9In3zEulipGfNaQ0Avj/Jhi1UbS9lJMVNNODZ0dzfkJhIlpkG z7+totPf5P1BdUBTNk7OpguDLsb5DXKm5ZhGSDzMgGGNDNdOEZpJJ1zVjskUkmR2 frea+ZcpMkNa9CB6Jf6d6oE2BNhW94d1F4N5KB0NbmFonzLa3N5vRHstM88DbFSO UM7N9SRf+8Jnviae7fcG12woE+25G4qB1wJ1rfIu9wL7JhiXLPA7FB4L4bRglXZs Vin9sY93QyUmrv8kxNrtwLXnQopu0myfG3CXAgMBAAGjgdowgdcwDAYDVR0TAQH/ BAIwADAdBgNVHQ4EFgQUvz2fdMwH1G1W8bbcAWN238szW34wgZcGA1UdIwSBjzCB jIAUvz2fdMwH1G1W8bbcAWN238szW36hXqRcMFoxCzAJBgNVBAYTAlVTMRMwEQYD VQQKDApjb2Rlc3R1ZGlvMRUwEwYDVQQLDAxPbmVMb2dpbiBJZFAxHzAdBgNVBAMM Fk9uZUxvZ2luIEFjY291bnQgODg5ODiCFCGJQKxcVgdQuwV+qv5hcrQiGHiPMA4G A1UdDwEB/wQEAwIHgDANBgkqhkiG9w0BAQUFAAOCAQEANkaO/xJag1n93l+6/sbl cG/1Oi3/hI19+lp0PU26kFtkrpzfjE4QugBgnGXkeJ/MU6abk650uh+7yLqkY15G m9Lsk0XiH1k7vWWnQl12Yj0uwCY47baBLw0lMCl5vNaJcULicAM715W3d2oHptnh ftePShyHHD69Z4e+UduuClbXjSxPNB9zTOsLYRVbrX+fIFm1AK8bWcmrH/jAuj7p WP7hRJdT3jG5N7LNb4th3Ojj47NksjaPo2nOuydZvyoL2CJ/E2qJeW78V6oqXCB3 D/XVIWWdUmYMNNmXksT9MJCtZWvnV3OmdYbyZjOK2bJK7fbVgm/gwpeBSY+pquMG AA==</ds:X509Certificate> </ds:X509Data> </ds:KeyInfo> </KeyDescriptor> <SingleLogoutService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://codestudio-dev.onelogin.com/trust/saml2/http-redirect/slo/575443\"/> <NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress</NameIDFormat> <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://codestudio-dev.onelogin.com/trust/saml2/http-redirect/sso/575443\"/> <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" Location=\"https://codestudio-dev.onelogin.com/trust/saml2/http-post/sso/575443\"/> <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:SOAP\" Location=\"https://codestudio-dev.onelogin.com/trust/saml2/soap/sso/575443\"/> <SingleLogoutService Location=\"https://codestudio-dev.onelogin.com/trust/saml2/http-redirect/slo/575443\" Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\"/> </IDPSSODescriptor> <ContactPerson contactType=\"technical\"> <SurName>Support</SurName> <EmailAddress>support@onelogin.com</EmailAddress> </ContactPerson> </EntityDescriptor>" * ; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = * dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(xml.getBytes("UTF-8"))); * * DOMMetadataProvider pro = new DOMMetadataProvider(doc.getDocumentElement()); pro.setParserPool(parserPool); pro.initialize(); */ ExtendedMetadataDelegate emd = new ExtendedMetadataDelegate(pro, em); /* * Set metadata provider and add filter to chain */ MetadataManager metadata = context.getBean(MetadataManager.class); metadata.addMetadataProvider(emd); metadata.refreshMetadata(); metadataGeneratorFilter.setManager(metadata); getNestedFilters().add(metadataGeneratorFilter); } else { LOGGER.log(Level.FINE, "Metadata filter already added"); } /* * Inject UserGroup and Role configuration into SAML user details service */ SAMLUserDetailsServiceImpl usd = context.getBean(SAMLUserDetailsServiceImpl.class); usd.setConverter(this.getConverter()); usd.setRoleServiceName(this.getRoleServiceName()); usd.setRolesHeaderAttribute(this.getRolesHeaderAttribute()); usd.setRoleSource(this.getRoleSource()); usd.setSecurityManager(this.securityManager); usd.setUserGroupServiceName(this.getUserGroupServiceName()); } catch (Exception ex) { throw new RuntimeException(ex); } }