juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svi...@apache.org
Subject svn commit: r421919 - in /webservices/juddi/trunk/extras/jbossauthenticator: ./ src/ src/org/ src/org/apache/ src/org/apache/juddi/ src/org/apache/juddi/auth/ src/org/apache/juddi/auth/JBossAuthenticator.java
Date Fri, 14 Jul 2006 15:00:25 GMT
Author: sviens
Date: Fri Jul 14 08:00:25 2006
New Revision: 421919

URL: http://svn.apache.org/viewvc?rev=421919&view=rev
Log:
Moving JBossAuthenticator out of the core source library

Added:
    webservices/juddi/trunk/extras/jbossauthenticator/
    webservices/juddi/trunk/extras/jbossauthenticator/src/
    webservices/juddi/trunk/extras/jbossauthenticator/src/org/
    webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/
    webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/
    webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/
    webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/JBossAuthenticator.java

Added: webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/JBossAuthenticator.java
URL: http://svn.apache.org/viewvc/webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/JBossAuthenticator.java?rev=421919&view=auto
==============================================================================
--- webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/JBossAuthenticator.java
(added)
+++ webservices/juddi/trunk/extras/jbossauthenticator/src/org/apache/juddi/auth/JBossAuthenticator.java
Fri Jul 14 08:00:25 2006
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juddi.auth;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.error.RegistryException;
+import org.apache.juddi.error.UnknownUserException;
+import org.apache.juddi.util.Config;
+import org.jboss.security.AuthenticationManager;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.security.Principal;
+
+/**
+ * This is a implementation of jUDDI's Authenticator interface, 
+ * that uses the JBoss authentication manager.
+ * 
+ * Usage:
+ * 
+ *   To use this class you must add the following properties
+ *   to the juddi.properties file:
+ * 
+ *    # The JBoss Authenticator 
+ *    juddi.auth=org.apache.juddi.auth.JBossAuthenticator
+ *  
+ *    # The security-domain, defined in $JBOSS/default/conf/login-config.xml 
+ *    juddi.securityDomain=java:/jaas/other
+ *  
+ * @author Antoni Reus (areus@ibit.org)
+ */
+public class JBossAuthenticator implements Authenticator 
+{
+  // private reference to the jUDDI logger
+  private static Log log = LogFactory.getLog(JBossAuthenticator.class);
+  
+  // static default security-domain to use.
+  private static final String SECURITY_DOMAIN_KEY = "juddi.securityDomain";
+  private static final String DEFAULT_SECURITY_DOMAIN = "java:/jaas/other";
+  
+  // JBoss authentication manager
+  AuthenticationManager authManager;
+
+  /**
+   *
+   */
+  public JBossAuthenticator() 
+  {
+    init();
+  }
+  
+  /**
+   *
+   */
+  public String authenticate(final String userID, final String credential)
+    throws RegistryException 
+  {
+    if (userID == null) {
+      throw new UnknownUserException("Invalid user ID = "+userID);
+    }
+  
+    // Create a principal for the userID
+    Principal principal = new Principal() 
+    {
+      public String getName() {
+        return userID;
+      }
+    };
+    
+    if (!authManager.isValid(principal, credential)) {
+      throw new UnknownUserException("Invalid credentials");
+    }
+    
+    return userID;
+  }
+
+
+  private void init() 
+  {
+    String securityDomain = Config.getStringProperty(SECURITY_DOMAIN_KEY,DEFAULT_SECURITY_DOMAIN);
+
+    try {
+      // lookup for the authentication manager.
+      Context ctx = new InitialContext();
+      authManager = (AuthenticationManager) ctx.lookup(securityDomain);
+      ctx.close();
+    } catch (NamingException e) {
+      log.error("JNDI Exception looking for autentication manager: " + 
+        securityDomain, e);
+    }
+  }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message