[10:51:19 CDT(-0500)] <fairwinds> apetro: good afternoon. Well I am almost there with my handler. Have the java now in maven that does the connecting to couch to verify password over secure connection using Basic auth. So next step is putting into AuthenticationHandler class and to set up something so connection parameters can be set in xml configuration
[10:52:08 CDT(-0500)] <fairwinds> apetro: I have to say I am rubbish with maven so it was a bit bumpy
[11:34:39 CDT(-0500)] <fairwinds> apetro: I guess I will need a bean factory to get couchdb properties.
[11:35:40 CDT(-0500)] <fairwinds> was looking at memcached client. perhaps I can use org.springframework.beans.factory.FactoryBean
[13:18:54 CDT(-0500)] <apetro> fairwinds, how's it going?
[13:19:09 CDT(-0500)] <fairwinds> apetro: pretty good actually
[13:19:12 CDT(-0500)] <fairwinds>
[13:19:23 CDT(-0500)] <fairwinds> weather is cooler and code going well
[13:19:39 CDT(-0500)] <apetro> glad to hear it
[13:20:03 CDT(-0500)] <fairwinds> I am just getting xml configuration to work for my db connection
[13:20:40 CDT(-0500)] <fairwinds> so creating a bean for couchdbConnection
[13:21:55 CDT(-0500)] <fairwinds> apetro: and will get hold of that object in my handler through spring ApplicationContext is way I am going at it
[13:26:09 CDT(-0500)] <fairwinds> sort of an interesting adventure. I don't really program in Java
[13:31:32 CDT(-0500)] <apetro> k
[13:31:42 CDT(-0500)] <apetro> if you've got code you'd like looked over at some point
[13:31:57 CDT(-0500)] <apetro> mostly you probably shouldn't have to be calling out to the ApplicationContext from Java code
[13:32:02 CDT(-0500)] <apetro> the idea is that Spring wires it all together for you
[13:32:15 CDT(-0500)] <apetro> so mostly your code is a victim of rather than an invoker of Spring, as it were
[13:32:22 CDT(-0500)] <apetro> but whatever works for you
[13:39:47 CDT(-0500)] <fairwinds> apetro: it would be great if you could have a look. I am going to finish it up first so that the thing all works. Then it can be made better from there. I am a bit ignorant of much of the structure so there will no doubt be some likely improvements after I finish this first go of it
[13:40:45 CDT(-0500)] <apetro> that's fine. getting to working code is certainly the most important consideration – can infinitely refactor from there
[13:42:01 CDT(-0500)] <fairwinds> apetro: I mean I will want to know if there is a better place to put somethings or some better classes to use. I have been careful to minimize dependencies
[13:43:41 CDT(-0500)] <apetro> that all sounds fair. having myself gone down the road of static factories invoking Spring and so forth, I know it is possible to get pretty stuck. Don't stay stuck.
[13:48:51 CDT(-0500)] <fairwinds> So far I am good but will make some noise if things get painful. I am having fun with this in general. I mostly code with javascript on server these days which is quite a bit faster that Java but obviously no CAS server there yet.
[16:25:19 CDT(-0500)] <fairwinds> apetro: ping
[16:25:28 CDT(-0500)] <apetro> pong
[16:27:13 CDT(-0500)] <fairwinds> hi.. I have created some xml and a class to instantiate my couchdb connection. I am wondering how to get a handle on it
[16:28:12 CDT(-0500)] <fairwinds> apetro. I was going to use ApplicationContext and ClassPathXMLApplicationContext
[16:28:36 CDT(-0500)] <apetro> yeah. You're going down a road that's not going to work very well.
[16:29:34 CDT(-0500)] <apetro> Let's talk about Spring for a bit.
[16:29:54 CDT(-0500)] <fairwinds> ie. ApplicationContext context = new ClassPathXMLApplicationContext("some.xml");
[16:29:58 CDT(-0500)] <fairwinds> CouchDBConnection couchDBConn = (CouchDBConnection) context.getBean("couchDBConnection");
[16:30:02 CDT(-0500)] <fairwinds> somethign like that
[16:30:05 CDT(-0500)] <apetro> yeah
[16:30:10 CDT(-0500)] <apetro> you could do that
[16:30:23 CDT(-0500)] <fairwinds> is there a better way
[16:30:27 CDT(-0500)] <apetro> there is
[16:30:55 CDT(-0500)] <apetro> so you have an XML file that defines some Spring beans?
[16:31:00 CDT(-0500)] <apetro> that's what some.xml is?
[16:31:33 CDT(-0500)] <fairwinds> well I put my bean in deployerConfigContext.xml for time being until I talked to you
[16:31:41 CDT(-0500)] <apetro> if so, simply drop it into the spring-configuration directory, and CAS will bootstrap it in among the spring-wired beans
[16:32:02 CDT(-0500)] <apetro> then, rather than your code instantiating a context and doing context.getBean()
[16:32:36 CDT(-0500)] <apetro> simply expose as JavaBean property (i.e. getCouchDbConnection() and setCouchDbConnection() ) in your AuthenticationHandler implementation
[16:33:15 CDT(-0500)] <apetro> and then in deployerConfigContext, where you declare your custom AuthenticationHandler implementation, wire into it the couchDBConnection
[16:34:25 CDT(-0500)] <apetro> I guess the main advice I'm offering is, don't write any Java that itself creates new Spring ApplicationContexts
[16:34:38 CDT(-0500)] <apetro> rather, whatever your object needs, let Spring provide it via dependency injection
[16:34:58 CDT(-0500)] <apetro> and wire up those dependencies in XML, whether in deployerConfigContext.xml, or in another XML file, as you liek.
[16:35:01 CDT(-0500)] <apetro> like, even.
[16:35:33 CDT(-0500)] <fairwinds> right. I was looking at code for memcached and jdbc. These things are configured in deployerConfigContext.xml are they not?
[16:35:41 CDT(-0500)] <apetro> yes
[16:35:44 CDT(-0500)] <fairwinds> I mean the connection itself
[16:35:48 CDT(-0500)] <apetro> well
[16:35:58 CDT(-0500)] <apetro> in the case of JDBC, the DataSource, that is, the connection factory
[16:36:05 CDT(-0500)] <fairwinds> right
[16:36:15 CDT(-0500)] <fairwinds> I read the datasource thing
[16:36:26 CDT(-0500)] <apetro> I don't know enough about what a CouchDbConnection is to be comfortable saying whether you should be wiring up that or a factory for that in deployerConfigContext.xml
[16:36:37 CDT(-0500)] <apetro> but yes, that's generally the idea
[16:37:07 CDT(-0500)] <apetro> in the case of JDBC, one wires up a DataSource, and then injects that DataSource into the JDBCWhateverWhateverAuthenticationHandler
[16:37:14 CDT(-0500)] <fairwinds> well, my CouchDBConnection is just a simple object that creates a hostAddress really.
[16:37:27 CDT(-0500)] <fairwinds> with the properties from the xml configuration
[16:37:27 CDT(-0500)] <apetro> cool
[16:37:31 CDT(-0500)] <apetro> yeah
[16:37:45 CDT(-0500)] <apetro> so, what properties does it need?
[16:38:07 CDT(-0500)] <apetro> and what XML configuration is this?
[16:38:23 CDT(-0500)] <apetro> Unfortunately, I know zero about CouchDb.
[16:38:29 CDT(-0500)] <apetro> but given that
[16:38:32 CDT(-0500)] <fairwinds> hey, let me paste waht I have
[16:38:37 CDT(-0500)] <apetro> that'd be fine
[16:39:18 CDT(-0500)] <apetro> bonus points for using gist
[16:42:00 CDT(-0500)] <apetro> but mostly the game is this:
[16:42:14 CDT(-0500)] <apetro> whatever your AuthenticationHandler needs, express it as JavaBean properties
[16:42:25 CDT(-0500)] <apetro> that is, methods with names getSomething() and setSomething()
[16:42:49 CDT(-0500)] <apetro> then, in deployerConfigContext.xml , declare your AuthenticationHandler, fulfilling its required setSomething()s by injection
[16:43:36 CDT(-0500)] <apetro> for getting started, I'd suggest sticking with simple such properties (integers and strings) and just put them all right in AuthenticationHandler, refactor out to a more complex external connection factory and so forth later after you've got working code
[16:44:01 CDT(-0500)] <apetro> and mostly, at that point , you should need no additional XML files and no manual bootstrapping of Spring contexts
[16:44:31 CDT(-0500)] <fairwinds> apetro: k, here is first gist
[16:44:36 CDT(-0500)] <fairwinds> https://gist.github.com/31a3f419468b602a06ac
[16:44:44 CDT(-0500)] <fairwinds> this is just the bean
[16:45:38 CDT(-0500)] <apetro> k
[16:45:40 CDT(-0500)] <apetro> that looks fine
[16:45:49 CDT(-0500)] <apetro> you can put that right in deployerConfigContext.xml
[16:45:56 CDT(-0500)] <fairwinds> yup, I did
[16:45:57 CDT(-0500)] <apetro> as a child of <beans/>
[16:45:59 CDT(-0500)] <apetro> cool
[16:46:04 CDT(-0500)] <fairwinds> k, here is next
[16:46:07 CDT(-0500)] <fairwinds> https://gist.github.com/3a276edcb351c653fe0f
[16:46:19 CDT(-0500)] <fairwinds> this is the class I want to instantiate with it
[16:47:00 CDT(-0500)] <apetro> yup
[16:47:06 CDT(-0500)] <apetro> that looks just fine
[16:49:25 CDT(-0500)] <fairwinds> k, next up is what I will be turning into the authentication handler
[16:49:29 CDT(-0500)] <fairwinds> https://gist.github.com/367ab3152b25fdfcb975
[16:50:38 CDT(-0500)] <apetro> yup
[16:50:50 CDT(-0500)] <apetro> so, add a Javabean property named couchDbConnection or so
[16:50:54 CDT(-0500)] <apetro> so then in your AuthenticationHandler declaration, you'd simply have a p:couchDbConnection="couchDBConnection"
[16:51:26 CDT(-0500)] <apetro> where the part after the p: is the name of the JavaBean property, and the value of the XML attribute is the name of the bean that fulfills the dependenchy
[16:51:38 CDT(-0500)] <fairwinds> ah, cool
[16:52:15 CDT(-0500)] <apetro> so, back on your CouchDBConnection object : https://gist.github.com/3a276edcb351c653fe0f
[16:52:26 CDT(-0500)] <fairwinds> my code is will be much better afterwards, this stuff in here I started by getting a jar to work with my couchdb
[16:52:29 CDT(-0500)] <apetro> I really don't think that's going to work unless you do add the JavaBean properties
[16:52:51 CDT(-0500)] <apetro> for instance, there should be a setHost() and getHost() method
[16:53:27 CDT(-0500)] <apetro> that's what those property declarations here https://gist.github.com/31a3f419468b602a06ac do, is call the corresponding set methods
[16:55:26 CDT(-0500)] <fairwinds> apetro: so just to confirm some things
[16:55:50 CDT(-0500)] <fairwinds> 1. I leave my bean in deployerConfigContext.xml as is
[16:57:13 CDT(-0500)] <fairwinds> 2. In my authenticationHandler, I make a declaration p:couchDbConnection="couchDBConnection"
[16:59:27 CDT(-0500)] <fairwinds> apetro: there are only two things I need from the bean. The hostaddress and encodedAuthorization
[17:01:30 CDT(-0500)] <apetro> in deployerConfigContext, you'll have a bean declaration that looks something like <bean class="com.automorpheus.cas.adapters.CouchDBAuthenticationHandler" p:couchDbConnection="couchDBconnection" />
[17:01:49 CDT(-0500)] <fairwinds> yup
[17:02:08 CDT(-0500)] <apetro> that will cause Spring to call setCouchDbConnection() on your authentication handler with the argument to the method call being that couchDBConnection bean
[17:02:47 CDT(-0500)] <apetro> and then yes, in your implementation of the authentication handler, you'd then call those two custom methods you've made on that bean, to get the host address and encoded authorization when you need them
[17:02:55 CDT(-0500)] <fairwinds> ah, light bulb goes on
[17:03:10 CDT(-0500)] <fairwinds>
[17:03:21 CDT(-0500)] <apetro> so Spring will call that set method on your bean sometime before your bean ever has to do any work
[17:03:52 CDT(-0500)] <fairwinds> then use a get method to use the object
[17:04:03 CDT(-0500)] <apetro> and then inside your implementation of the AuthenticationHandler API methods, you can assume the couchDbConnection bean is already set, there waiting for you and available for you to call upon in your custom implementation of the API method
[17:04:17 CDT(-0500)] <fairwinds> right
[17:04:23 CDT(-0500)] <apetro> yeah
[17:04:28 CDT(-0500)] <apetro> mostly the get methods are just for good form
[17:04:43 CDT(-0500)] <apetro> some of the JavaBean library support chokes if the get methods aren't there
[17:04:48 CDT(-0500)] <apetro> but mostly Spring doesn't care
[17:04:54 CDT(-0500)] <fairwinds> sure, well I want to be in good form
[17:04:55 CDT(-0500)] <apetro> it's not going to call your get methods
[17:05:02 CDT(-0500)] <fairwinds> right
[17:05:28 CDT(-0500)] <apetro> and mostly you don't care either. you're not going to call getHost(), but you are going to call couchDbConnection.getHostAddress()
[17:06:07 CDT(-0500)] <apetro> yup
[17:06:09 CDT(-0500)] <fairwinds> exaclty. that authentication handler is just a bunch of code I started in a jar
[17:06:28 CDT(-0500)] <fairwinds> I just wanted to make sure my connection was working to couchdb first
[17:06:45 CDT(-0500)] <apetro> you're doing fine, but if you're looking for a book recommendation, iirc Manning's Spring in Action is getting really dated but is nonetheless a great intro to Spring and covers all this basic bean wiring we're talking about here.
[17:06:53 CDT(-0500)] <fairwinds> and it does work so not need to implement some proper authenticatin class
[17:07:00 CDT(-0500)] <apetro> yup. that's a fine approach.
[17:07:15 CDT(-0500)] <fairwinds> you make me fee much better
[17:07:50 CDT(-0500)] <fairwinds> thank you for that, I will look for an ebook to buy
[17:08:54 CDT(-0500)] <fairwinds> I just don't do very much in java at this point and this is good experience.
[17:09:16 CDT(-0500)] <fairwinds> I am learning quite a bit about maven and cas both
[17:09:24 CDT(-0500)] <fairwinds> and now spring
[17:10:11 CDT(-0500)] <fairwinds> apetro: I will get going on my changes. I really appreciate your help
[17:10:33 CDT(-0500)] <fairwinds> it has helped me better understand
[17:12:45 CDT(-0500)] <fairwinds> I am going to read the AbstractUsernamePasswordAuthenticationHandler to see if I should be inheriting from this
[17:15:34 CDT(-0500)] <fairwinds> apetro: basically all this code does is connect to couchdb and look up a user in the database, retrieve the salf of the password. Then I take sha1 of password plus the salt to create the password_sha1 value. If this matches the value in the database, user will authenticate.
[17:18:37 CDT(-0500)] <apetro> sounds good to me
[17:21:15 CDT(-0500)] <fairwinds> k, cool
[19:31:30 CDT(-0500)] <fairwinds> apetro: hi. I have a second draft of handler to show
[20:22:16 CDT(-0500)] <fairwinds> apetro: hi. I am running into a problem with my build. It is not seeing the imports to cas for some reason ie .import org.jasig.cas.authentication.principal.UsernamePasswordCredentials;
[20:23:43 CDT(-0500)] <fairwinds> seems all others are fine. Wondering if this has to do with structure of my project. Will play a bit with this
[21:01:27 CDT(-0500)] <fairwinds> k, got it to compile by adding cas-server-core to dependencies
[21:06:53 CDT(-0500)] <fairwinds> but it does not seem to find my package ie. java.lang.ClassNotFoundException with my handler. I am sure is likely a maven thing.
[21:15:39 CDT(-0500)] <fairwinds> apetro: or maybe I need to add my auth handler to webapp dependencies. I will try that
[21:15:55 CDT(-0500)] <fairwinds> and include in my overlay
[22:23:45 CDT(-0500)] <apetro> yeah, your overlay needs to declare all its dependencies
[22:23:58 CDT(-0500)] <apetro> if your authhandler Java implementation is in a separate project from the overlay, then
[22:24:05 CDT(-0500)] <apetro> 1) your overlay needs to declare dependency on it, and
[22:24:20 CDT(-0500)] <apetro> 2) don't do that. Instead, just inline your auth handler Java code into your maven overlay project until you have it all working.
[22:24:36 CDT(-0500)] <fairwinds> apetro: hi
General
Content
Integrations