Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r190 - branches/rest/java/ch/idok/service/server/rest

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r190 - branches/rest/java/ch/idok/service/server/rest


Chronological Thread 
  • From: "AFS account Roman Geus" <geus AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r190 - branches/rest/java/ch/idok/service/server/rest
  • Date: Tue, 26 Aug 2008 17:35:46 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: geus
Date: Tue Aug 26 17:35:45 2008
New Revision: 190

Log:
Extracted idok-specific code from NegotiateFilter to IdokNegotiateFilter


Added:
branches/rest/java/ch/idok/service/server/rest/IdokNegotiateFilter.java

Added: branches/rest/java/ch/idok/service/server/rest/IdokNegotiateFilter.java
==============================================================================
--- (empty file)
+++ branches/rest/java/ch/idok/service/server/rest/IdokNegotiateFilter.java
Tue Aug 26 17:35:45 2008
@@ -0,0 +1,71 @@
+package ch.idok.service.server.rest;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.restlet.data.Request;
+
+import ch.idok.common.errorhandling.DmsException;
+import ch.idok.common.util.AuthUtil;
+import ch.idok.common.util.DmsCredentials;
+import ch.idok.common.util.DummyCallbackHandler;
+import ch.idok.common.util.Krb5DmsCredentials;
+
+/**
+ * NegotiateFilter with iDok specific functionality
+ */
+public class IdokNegotiateFilter extends NegotiateFilter {
+
+ /**
+ * The login configuration used for checking username and password for
BASIC
+ * authentication scheme
+ */
+ private String jaasLoginConfig;
+
+ public IdokNegotiateFilter(String realm, String jaasLoginConfig) {
+ super(realm);
+ }
+
+ /**
+ * Return a DmsCredentials object created from the current Restlet
request.
+ *
+ * @throws DmsException
+ */
+ static public DmsCredentials getDmsCredentials() throws DmsException {
+ Request request = Request.getCurrent();
+ Subject subject = (Subject) request.getAttributes().get(
+ subjectAttributeName);
+ char[] password = (char[])
request.getChallengeResponse().getSecret();
+
+ return new Krb5DmsCredentials(AuthUtil.getUserPrincipal(subject)
+ .getName(), password, subject);
+ }
+
+ /**
+ * Check the username/password combination using a JAAS login
+ *
+ * @return the authenticated Subject if successful, null otherwise
+ */
+ @Override
+ protected Subject checkSecret(Logger logger, Request request,
+ String identifier, char[] secret) {
+ CallbackHandler handler = new DummyCallbackHandler(identifier,
secret);
+
+ try {
+ LoginContext lc = new LoginContext(jaasLoginConfig, handler);
+ lc.login();
+ logger.finer("Authentication successful for user " + identifier);
+ return lc.getSubject();
+ } catch (LoginException e) {
+ logger.log(Level.FINER, "Authentication failed for user "
+ + identifier, e);
+ return null;
+ }
+ }
+
+}



  • [idok-commit] idok commit r190 - branches/rest/java/ch/idok/service/server/rest, AFS account Roman Geus, 08/26/2008

Archive powered by MHonArc 2.6.19.

Top of Page