Child pages
  • Grouper XMPP notifications
Skip to end of metadata
Go to start of metadata

 This topic is discussed in the Advanced Topics training video.

Grouper has a basic change log consumer implementation which can send XMPP or HTTPS notifications (see ESB documentation).  The loader sends the XMPP messages.  If you want, the grouper client can listen on an XMPP channel for events and kick off logic.  There is built in logic to maintain a text file of users with prefix/suffix/expression language.  On an XMPP message, the client can either use the diff, or it can do a full refresh (if you don't  trust your Jabber deployment security or reliability).  The client will also periodically do a full refresh (on a quartz cron schedule, e.g. nightly)

Configure the grouper.loader.properties

changeLog.consumer.xmpp.class = edu.internet2.middleware.grouper.changeLog.esb.consumer.EsbConsumer
changeLog.consumer.xmpp.quartzCron = 0 * * * * ?

# match all events that are add or remove membership, only flattened,
# if the subject is from the jdbc source, with the loginid attribute and in the folder test:xmppGroups
changeLog.consumer.xmpp.elfilter = (event.eventType eq 'MEMBERSHIP_DELETE' || event.eventType eq 'MEMBERSHIP_ADD') && event.membershipType == 'flattened' && event.subjectHasAttribute('loginid') && event.sourceId == 'jdbc' && event.groupName =~ '^test\\:xmppGroups\\:.*$'

changeLog.consumer.xmpp.publisher.class = edu.internet2.middleware.grouper.changeLog.esb.consumer.EsbXmppPublisher

#add in the recipients
changeLog.consumer.xmpp.publisher.recipient = user@school.edu/Home, grouperjabber@school.edu/grouperClient

changeLog.consumer.xmpp.publisher.addSubjectAttributes = loginid

##################################### XMPP notifications defaults ###################################
## general xmpp configuration

xmpp.server.host = jabber.school.edu
xmpp.server.port = 5222
xmpp.user = grouperjabber

# note, pass can be in an external file with morphstring
xmpp.pass = abcabcabc
xmpp.resource = grouperServer

Run the loader as usual:

gsh \-loader

Add some group/member:

gsh 0% grouperSession = GrouperSession.startRootSession();
gsh 1% new GroupSave(grouperSession).assignName("test:xmppGroups:group1").assignCreateParentStemsIfNotExist(true).save();
gsh 2% addMember("test:xmppGroups:group1", "test.subject.0");

See an XMPP notification (JSON):

{   "esbEvent":[
     {
       "eventType":"MEMBERSHIP_ADD",
       "fieldName":"members",
       "groupId":"80ea7edaba7f4c8b9315b5e5f90c8f45",
       "groupName":"test:xmppGroups:group1",
       "membershipType":"flattened",
       "sequenceNumber":"50",
       "sourceId":"jdbc",
       "subjectAttributes":[
         [
           "loginid",
           "id.test.subject.1"
         ]
       ]
       ,
       "subjectId":"test.subject.1"
     }
   ]
 }

Configure the grouper.client.properties

################################
## XMPP client settings ## Note: you need the smack.jar in your classpath, see the grouper xmpp wiki for usage
## https://spaces.internet2.edu/display/GrouperWG/Grouper+XMPP+notifications+v1.6.0
################################
## general xmpp configuration
grouperClient.xmpp.server.host = jabber.school.edu grouperClient.xmpp.server.port = 5222
grouperClient.xmpp.user = grouperuser # note, pass can be in an external file with morphstring
grouperClient.xmpp.pass = **********
grouperClient.xmpp.resource = grouperClient
grouperClient.xmpp.trustedMessagesFromJabberIds = grouperuser@upenn.edu/grouperServer
grouperClient.xmpp.job.myJobName.groupNames = test:xmppGroups:group1
grouperClient.xmpp.job.myJobName.handlerClass = edu.internet2.middleware.grouperClientExt.xmpp.GrouperClientXmppFileHandler
# set this to reload_group or incremental if not reload on each event
grouperClient.xmpp.job.myJobName.eventAction = incremental
# how often a full refresh should occur regardless of events
grouperClient.xmpp.job.myJobName.fullRefreshQuartzCronString =
grouperClient.xmpp.job.myJobName.fileHandler.targetFile = c:/temp/xmpp/target.txt
grouperClient.xmpp.job.myJobName.fileHandler.filePrefix = c:/temp/xmpp/prefix.txt
grouperClient.xmpp.job.myJobName.fileHandler.iteratorEl = ${subject.attribute['loginid']}$space$
grouperClient.xmpp.job.myJobName.fileHandler.fileSuffix = c:/temp/xmpp/suffix.txt # subjects wont notify if not match this filter
grouperClient.xmpp.job.myJobName.elfilter = (event.eventType eq 'MEMBERSHIP_DELETE' || event.eventType eq 'MEMBERSHIP_ADD') && event.membershipType == 'flattened' && event.subjectHasAttribute('loginid') && event.sourceId == 'jdbc' && event.groupName = 'test:xmppGroups:group1'

Make sure Grouper WS is up and running and configured in grouper.client.properties

Setup a file prefix: c:/temp/xmpp/prefix.txt

require user

Setup a file suffix: c:/temp/xmpp/suffix.txt  (note, just put a newline in this file in this case)

 

The client needs a few more jars to work properly (xmpp library, and quartz for scheduling.  Startup with all those jars in classpath, and grouper.client.properties, here is a linux example

C:\temp\xmpp>dir *.jar
Volume in drive C is OS
Volume Serial Number is C899-F8B9
Directory of C:\temp\xmpp
04/28/2010  11:45 AM           173,783 commons-beanutils.jar
04/24/2010  03:12 AM           570,463 commons-collections.jar
04/28/2010  11:45 AM           468,109 commons-lang.jar
04/24/2010  03:12 AM           131,078 commons-logging.jar
04/28/2010  11:45 AM            86,542 ezmorph.jar
06/01/2010  06:12 AM         2,619,667 grouperClient.jar
04/28/2010  11:45 AM           255,813 json-lib.jar
04/24/2010  03:12 AM             8,374 jta.jar
04/24/2010  03:12 AM           792,769 quartz.jar
04/20/2010  03:14 AM         1,381,464 smack.jar
               10 File(s)      6,488,062 bytes
                0 Dir(s)  437,193,080,832 bytes free
C:\temp\xmpp> java -classpath .;* edu.internet2.middleware.grouperClientExt.xmpp.GrouperClientXmppMain
  • No labels