Skip to Content.
Sympa Menu

grouper-users - [grouper-users] RE: Notification from Consumer Class

Subject: Grouper Users - Open Discussion List

List archive

[grouper-users] RE: Notification from Consumer Class

Chronological Thread 
  • From: Chris Hyzer <>
  • To: "Klug, Lawrence" <>, "" <>
  • Subject: [grouper-users] RE: Notification from Consumer Class
  • Date: Thu, 4 Oct 2012 17:44:18 +0000
  • Accept-language: en-US


Check it out and look for HttpClient.  Here is an example from the discovery client in that grouperclient code.


        Map<String, Object> logMap = log.isDebugEnabled() ? new LinkedHashMap<String, Object>() : null;


        if (logMap != null) {

          logMap.put("method", "DiscoveryClient.retrieveFileFromDiscoveryServer.logic");



        //this is the URL

        String url = "failoverLogicBean.getConnectionName();


        //strip last slash

        url = "GrouperClientUtils.stripEnd(url, "/");


        String fileNameNoSlash = GrouperClientUtils.stripStart(fileNameOnServer, "/");


        String fullUrl = url + "/" + fileNameNoSlash;


        if (logMap != null) {

          logMap.put("fullUrl", fullUrl);



        //see if invalid SSL

        String httpsSocketFactoryName = GrouperClientUtils.propertiesValue("grouperClient.https.customSocketFactory", false);


        //is there overhead here?  should only do this once?

        //perhaps give a custom factory

        if (!GrouperClientUtils.isBlank(httpsSocketFactoryName)) {

          Class<? extends SecureProtocolSocketFactory> httpsSocketFactoryClass = GrouperClientUtils.forName(httpsSocketFactoryName);

          SecureProtocolSocketFactory httpsSocketFactoryInstance = GrouperClientUtils.newInstance(httpsSocketFactoryClass);

          Protocol easyhttps = new Protocol("https", httpsSocketFactoryInstance, 443);

          Protocol.registerProtocol("https", easyhttps);



        HttpClient httpClient = new HttpClient();



            HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));


        int soTimeoutMillis = GrouperClientUtils.propertiesValueInt(

            "grouperClient.discovery.httpSocketTimeoutMillis", 90000, false);



        httpClient.getParams().setParameter(HttpMethodParams.HEAD_BODY_CHECK_TIMEOUT, soTimeoutMillis);


        int connectionManagerMillis = GrouperClientUtils.propertiesValueInt(

            "grouperClient.discovery.httpConnectionManagerTimeoutMillis", 90000, false);




        String user = GrouperClientUtils.propertiesValue("", false);


        if (logMap != null) {

          logMap.put("user", user);



        if (!GrouperClientUtils.isBlank(user)) {




          boolean disableExternalFileLookup = GrouperClientUtils.propertiesValueBoolean(

              "encrypt.disableExternalFileLookup", false, true);


          //lets lookup if file

          String pass = GrouperClientUtils.propertiesValue("grouperClient.discovery.password", false);

          String passFromFile = GrouperClientUtils.readFromFileIfFile(pass, disableExternalFileLookup);


          String passPrefix = null;


          if (!GrouperClientUtils.equals(pass, passFromFile)) {


            passPrefix = "Discovery pass: reading encrypted value from file: " + pass;


            String encryptKey = GrouperClientUtils.encryptKey();

            pass = new Crypto(encryptKey).decrypt(passFromFile);


          } else {

            passPrefix = "Discovery pass: reading scalar value from";



          if (GrouperClientUtils.propertiesValueBoolean("grouperClient.logging.logMaskedPassword", false, false)) {

            if (logMap != null) {

              logMap.put(passPrefix, GrouperClientUtils.repeat("*", pass.length()));




          Credentials defaultcreds = new UsernamePasswordCredentials(user, pass);


          //set auth scope to null and negative so it applies to all hosts and ports

          httpClient.getState().setCredentials(new AuthScope(null, -1), defaultcreds);



        GetMethod getMethod = new GetMethod(fullUrl);


        getMethod.setRequestHeader("Connection", "close");


        try {


          int responseCodeInt = httpClient.executeMethod(getMethod);


          if (responseCodeInt != 200) {

            throw new RuntimeException("Expected 200, but received response code: " + responseCodeInt);



Then get the response, maybe as string? 








From: Klug, Lawrence [mailto:]
Sent: Thursday, October 04, 2012 1:36 PM
To: Chris Hyzer;
Subject: RE: Notification from Consumer Class


>> there are examples (e.g. in GrouperClient).


Can you point me to the examples?  Are they in SVN?






From: Chris Hyzer []
Sent: Thursday, October 04, 2012 10:23 AM
To: Klug, Lawrence;
Subject: RE: Notification from Consumer Class


Jakarta HttpClient is what we use, its already in Grouper, and there are examples (e.g. in GrouperClient).  I wouldn’t go lower level than that unless you really like reinventing things J





From: On Behalf Of Klug, Lawrence
Sent: Thursday, October 04, 2012 12:17 PM
Subject: [grouper-users] Notification from Consumer Class




I’d like to construct an GET request from my ChangeLogConsumer class for notification to an outside application(Plone).  I was thinking of using HTTPClient or just standard – any suggestions about this?





Archive powered by MHonArc 2.6.16.

Top of Page