This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to write a filter which gets the currently authenticated user data and uses it in the application. For now I simply want to pass the authenticated user data to System.out.println which just displays the username of the authenticated user. I'm writing the following classes:
I get confused trying to write the LoginMatcher which should search through the database and match the remoteUser to the right record on the database, using only the username :
I'm not sure if the argument of the find method should be passed as a String or LoginFilter object or Member object. No matter which one of these types I set remoteUser in in the LoginMatcher class I get:
Member member = memsearch.find(remoteUser);
reason: actual argument String cannot be converted to Member by method invocation conversion
Would really appreciate any advice on what I'm doing wrong and how to correctly write the LoginMatcher class. Thanks!
Looking in the find method in LoginMatcher, why is it returning find(remoteUser) again when now the remoteUser is an Object? Is this find another overloaded method?
I don't think find() is an overloaded method, since it is intended to return a remoteUser which is of object type Member. I'm not even sure it overrides an existing find method (looking at the APIs of the imports).
Also the provided find method doesn't return a Member but a LoginFilter. But in your filter class it's returning a Member
Yes, it needs to return a Member as mentioned above. So, I would like to know how to correctly write the LoginMatcher class so that it iterates through the DB records, provides a match between the remoreUser String and the member object in the database and returns the remoteUser based on the identified member object. Please let me know if that flow logic makes sense.
If not I'll just go back to the drawing board. Thank you!