Author: kwright
Date: Sun Jun 28 23:04:30 2015
New Revision: 1688076

URL: http://svn.apache.org/r1688076
Log:
Add api login stuff and default authenticaator

Added:
    
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
   (with props)
Modified:
    
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/LdapAuthenticator.java
    
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IAuth.java

Added: 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java?rev=1688076&view=auto
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
 (added)
+++ 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
 Sun Jun 28 23:04:30 2015
@@ -0,0 +1,82 @@
+/* $Id$ */
+
+/**
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You 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.manifoldcf.core.auth;
+
+import org.apache.manifoldcf.core.interfaces.*;
+
+/** Default authenticator for MCF system.
+*/
+public class DefaultAuthenticator implements IAuth
+{
+
+  /** UI login user name */
+  public static final String loginUserNameProperty = 
"org.apache.manifoldcf.login.name";
+  /** UI login password */
+  public static final String loginPasswordProperty = 
"org.apache.manifoldcf.login.password";
+
+  /** API login user name */
+  public static final String apiLoginUserNameProperty = 
"org.apache.manifoldcf.apilogin.name";
+  /** API login password */
+  public static final String apiLoginPasswordProperty = 
"org.apache.manifoldcf.apilogin.password";
+
+  protected final String loginUserName;
+  protected final String loginPassword;
+  protected final String apiLoginUserName;
+  protected final String apiLoginPassword;
+  
+  /** Constructor */
+  public DefaultAuthenticator(final IThreadContext threadContext)
+    throws ManifoldCFException {
+    loginUserName = 
LockManagerFactory.getStringProperty(threadContext,loginUserNameProperty,"admin");
+    loginPassword = 
LockManagerFactory.getPossiblyObfuscatedStringProperty(threadContext,loginPasswordProperty,"admin");
+
+    apiLoginUserName = 
LockManagerFactory.getStringProperty(threadContext,apiLoginUserNameProperty,"");
+    apiLoginPassword = 
LockManagerFactory.getPossiblyObfuscatedStringProperty(threadContext,apiLoginPasswordProperty,"");
+  }
+    
+  /** Verify UI login */
+  @Override
+  public boolean verifyUILogin(final String userId, final String password)
+    throws ManifoldCFException {
+    if (userId != null && password != null)
+    {
+      return userId.equals(loginUserName) &&  password.equals(loginPassword);
+    }
+    return false;
+  }
+
+  /** Verify API login */
+  @Override
+  public boolean verifyAPILogin(final String userId, final String password)
+    throws ManifoldCFException {
+    if (userId != null && password != null)
+    {
+      return userId.equals(apiLoginUserName) &&  
password.equals(apiLoginPassword);
+    }
+    return false;
+  }
+       
+  /** Check user capability */
+  public boolean checkCapability(final String userId, final int capability)
+    throws ManifoldCFException {
+    // MHL when we add capability support throught MCF
+    return true;
+  }
+  
+}
\ No newline at end of file

Propchange: 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/DefaultAuthenticator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/LdapAuthenticator.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/LdapAuthenticator.java?rev=1688076&r1=1688075&r2=1688076&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/LdapAuthenticator.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/auth/LdapAuthenticator.java
 Sun Jun 28 23:04:30 2015
@@ -56,10 +56,10 @@ public class LdapAuthenticator implement
   public LdapAuthenticator(final IThreadContext threadContext)
     throws ManifoldCFException {
     securityPrincipal = 
LockManagerFactory.getStringProperty(threadContext,SECURITY_PRINCIPLE,"???");
-    securityAuthenticationType = 
LockManagerFactory.getStringProperty(threadContext,SECURITY_AUTHENTICATION_TYPE,"???");
-    providerURLProperty = 
LockManagerFactory.getStringProperty(threadContext,PROVIDER_URL_PROPERTY,"???");
+    securityAuthenticationType = 
LockManagerFactory.getStringProperty(threadContext,SECURITY_AUTHENTICATION_TYPE,"simple");
+    providerURLProperty = 
LockManagerFactory.getStringProperty(threadContext,PROVIDER_URL_PROPERTY,"");
     contextSearchQuery = 
LockManagerFactory.getStringProperty(threadContext,CONTEXT_SEARCH_QUERY,"???");
-    searchAttribute = 
LockManagerFactory.getStringProperty(threadContext,SEARCH_ATTRIBUTE,"???");
+    searchAttribute = 
LockManagerFactory.getStringProperty(threadContext,SEARCH_ATTRIBUTE,"uid");
   }
   
   /**
@@ -102,8 +102,20 @@ public class LdapAuthenticator implement
    * @return
    */
   @Override
-  public boolean verifyLogin(final String userId, final String password)
+  public boolean verifyUILogin(final String userId, final String password)
     throws ManifoldCFException {
+    return verifyLogin(userId, password);
+  }
+  
+  @Override
+  public boolean verifyAPILogin(final String userId, final String password)
+    throws ManifoldCFException {
+    return verifyLogin(userId, password);
+  }
+
+  protected boolean verifyLogin(final String userId, final String password)
+    throws ManifoldCFException {
+
     boolean authenticated = false;
 
     if (StringUtils.isNotEmpty(userId) && StringUtils.isNotEmpty(password)) {

Modified: 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IAuth.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IAuth.java?rev=1688076&r1=1688075&r2=1688076&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IAuth.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1131/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/IAuth.java
 Sun Jun 28 23:04:30 2015
@@ -37,10 +37,14 @@ public interface IAuth
   /** Edit jobs */
   public final static int CAPABILITY_EDIT_JOBS = 5;
   
-  /** Verify login */
-  public boolean verifyLogin(final String userId, final String password)
+  /** Verify UI login */
+  public boolean verifyUILogin(final String userId, final String password)
     throws ManifoldCFException;
-  
+
+  /** Verify API login */
+  public boolean verifyAPILogin(final String userId, final String password)
+    throws ManifoldCFException;
+       
   /** Check user capability */
   public boolean checkCapability(final String userId, final int capability)
     throws ManifoldCFException;


Reply via email to