Adempiere 3.1.2
This commit is contained in:
parent
110f14a7f5
commit
64eca30fca
|
@ -2136,6 +2136,22 @@ public abstract class Doc
|
||||||
return 0;
|
return 0;
|
||||||
} // getUser2_ID
|
} // getUser2_ID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User Defined value
|
||||||
|
* @return User defined
|
||||||
|
*/
|
||||||
|
public int getValue (String ColumnName)
|
||||||
|
{
|
||||||
|
int index = p_po.get_ColumnIndex(ColumnName);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
Integer ii = (Integer)p_po.get_Value(index);
|
||||||
|
if (ii != null)
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} // getValue
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
// To be overwritten by Subclasses
|
// To be overwritten by Subclasses
|
||||||
|
|
|
@ -995,6 +995,23 @@ public class DocLine
|
||||||
return 0;
|
return 0;
|
||||||
} // getUser2_ID
|
} // getUser2_ID
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User Defined Column
|
||||||
|
* @param ColumnName column name
|
||||||
|
* @return user defined column value
|
||||||
|
*/
|
||||||
|
public int getValue(String ColumnName)
|
||||||
|
{
|
||||||
|
int index = p_po.get_ColumnIndex(ColumnName);
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
Integer ii = (Integer)p_po.get_Value(index);
|
||||||
|
if (ii != null)
|
||||||
|
return ii.intValue();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} // getValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
* @return String
|
* @return String
|
||||||
|
|
|
@ -339,6 +339,7 @@ public class Doc_Order extends Doc
|
||||||
BigDecimal grossAmt = getAmount(Doc.AMTTYPE_Gross);
|
BigDecimal grossAmt = getAmount(Doc.AMTTYPE_Gross);
|
||||||
|
|
||||||
// Commitment
|
// Commitment
|
||||||
|
FactLine fl = null;
|
||||||
if (as.isCreateCommitment())
|
if (as.isCreateCommitment())
|
||||||
{
|
{
|
||||||
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
Fact fact = new Fact(this, as, Fact.POST_Commitment);
|
||||||
|
@ -351,7 +352,7 @@ public class Doc_Order extends Doc
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||||
FactLine fl = fact.createLine (line, expense,
|
fl = fact.createLine (line, expense,
|
||||||
getC_Currency_ID(), cost, null);
|
getC_Currency_ID(), cost, null);
|
||||||
}
|
}
|
||||||
// Offset
|
// Offset
|
||||||
|
@ -383,7 +384,7 @@ public class Doc_Order extends Doc
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||||
FactLine fl = fact.createLine (line, expense,
|
fl = fact.createLine (line, expense,
|
||||||
getC_Currency_ID(), null, cost);
|
getC_Currency_ID(), null, cost);
|
||||||
}
|
}
|
||||||
// Offset
|
// Offset
|
||||||
|
@ -550,6 +551,7 @@ public class Doc_Order extends Doc
|
||||||
C_InvoiceLine_ID);
|
C_InvoiceLine_ID);
|
||||||
|
|
||||||
BigDecimal total = Env.ZERO;
|
BigDecimal total = Env.ZERO;
|
||||||
|
FactLine fl = null;
|
||||||
int C_Currency_ID = -1;
|
int C_Currency_ID = -1;
|
||||||
for (int i = 0; i < commitments.length; i++)
|
for (int i = 0; i < commitments.length; i++)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +569,7 @@ public class Doc_Order extends Doc
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
MAccount expense = line.getAccount(ProductCost.ACCTTYPE_P_Expense, as);
|
||||||
FactLine fl = fact.createLine (line, expense,
|
fl = fact.createLine (line, expense,
|
||||||
C_Currency_ID, null, cost);
|
C_Currency_ID, null, cost);
|
||||||
}
|
}
|
||||||
// Offset
|
// Offset
|
||||||
|
|
|
@ -762,6 +762,7 @@ public final class Fact
|
||||||
* Set Transaction name
|
* Set Transaction name
|
||||||
* @param trxName
|
* @param trxName
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
private void set_TrxName(String trxName)
|
private void set_TrxName(String trxName)
|
||||||
{
|
{
|
||||||
m_trxName = trxName;
|
m_trxName = trxName;
|
||||||
|
|
|
@ -117,6 +117,48 @@ public final class FactLine extends X_Fact_Acct
|
||||||
setAD_Client_ID(m_acct.getAD_Client_ID());
|
setAD_Client_ID(m_acct.getAD_Client_ID());
|
||||||
setAccount_ID (m_acct.getAccount_ID());
|
setAccount_ID (m_acct.getAccount_ID());
|
||||||
setC_SubAcct_ID(m_acct.getC_SubAcct_ID());
|
setC_SubAcct_ID(m_acct.getC_SubAcct_ID());
|
||||||
|
|
||||||
|
// User Defined References
|
||||||
|
MAcctSchemaElement ud1 = m_acctSchema.getAcctSchemaElement(
|
||||||
|
X_C_AcctSchema_Element.ELEMENTTYPE_UserElement1);
|
||||||
|
if (ud1 != null)
|
||||||
|
{
|
||||||
|
String ColumnName1 = ud1.getDisplayColumnName();
|
||||||
|
if (ColumnName1 != null)
|
||||||
|
{
|
||||||
|
int ID1 = 0;
|
||||||
|
if (m_docLine != null)
|
||||||
|
ID1 = m_docLine.getValue(ColumnName1);
|
||||||
|
if (ID1 == 0)
|
||||||
|
{
|
||||||
|
if (m_doc == null)
|
||||||
|
throw new IllegalArgumentException("Document not set yet");
|
||||||
|
ID1 = m_doc.getValue(ColumnName1);
|
||||||
|
}
|
||||||
|
if (ID1 != 0)
|
||||||
|
setUserElement1_ID(ID1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MAcctSchemaElement ud2 = m_acctSchema.getAcctSchemaElement(
|
||||||
|
X_C_AcctSchema_Element.ELEMENTTYPE_UserElement2);
|
||||||
|
if (ud2 != null)
|
||||||
|
{
|
||||||
|
String ColumnName2 = ud2.getDisplayColumnName();
|
||||||
|
if (ColumnName2 != null)
|
||||||
|
{
|
||||||
|
int ID2 = 0;
|
||||||
|
if (m_docLine != null)
|
||||||
|
ID2 = m_docLine.getValue(ColumnName2);
|
||||||
|
if (ID2 == 0)
|
||||||
|
{
|
||||||
|
if (m_doc == null)
|
||||||
|
throw new IllegalArgumentException("Document not set yet");
|
||||||
|
ID2 = m_doc.getValue(ColumnName2);
|
||||||
|
}
|
||||||
|
if (ID2 != 0)
|
||||||
|
setUserElement2_ID(ID2);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // setAccount
|
} // setAccount
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,8 +315,7 @@ public final class FactLine extends X_Fact_Acct
|
||||||
setUser2_ID (m_docLine.getUser2_ID());
|
setUser2_ID (m_docLine.getUser2_ID());
|
||||||
if (getUser2_ID() == 0)
|
if (getUser2_ID() == 0)
|
||||||
setUser2_ID (m_doc.getUser2_ID());
|
setUser2_ID (m_doc.getUser2_ID());
|
||||||
// User Defined
|
// References in setAccount
|
||||||
|
|
||||||
} // setDocumentInfo
|
} // setDocumentInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,21 +10,50 @@
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
* You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.ldap;
|
package org.compiere.ldap;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import org.compiere.ldap.*;
|
|
||||||
|
import javax.naming.AuthenticationException;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.ldap.InitialLdapContext;
|
||||||
|
|
||||||
|
import org.compiere.model.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
import com.sun.jndi.ldap.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LDAP Connection Handler
|
* LDAP Connection Handler
|
||||||
*
|
*
|
||||||
|
* Only "simple" authentication and the following protocol are supported:
|
||||||
|
* bind
|
||||||
|
* unbind
|
||||||
|
* search
|
||||||
|
* The following distinguished name are supported:
|
||||||
|
* o - organization
|
||||||
|
* ou - organization unit
|
||||||
|
* cn - common name
|
||||||
|
* Due to some of the ldap client might not unbind and close the connection,
|
||||||
|
* whenever error occurs and authenticate done, we will close the connection.
|
||||||
|
*
|
||||||
|
* Basically, tested with two type of ldap authentication, java client and
|
||||||
|
* apache ldap support.
|
||||||
|
* For the apache support, here's the tested definition:
|
||||||
|
* AuthType Basic
|
||||||
|
* AuthLDAPAuthoritative on
|
||||||
|
* AuthLDAPEnabled on
|
||||||
|
* AuthLDAPURL ldap://<ip address>:<port no>/o=<organization>,ou=<organization unit>?uid?sub
|
||||||
|
* The protocol for the apache ldap:
|
||||||
|
* - bind to server
|
||||||
|
* - search for the object name with user input userid
|
||||||
|
* - bind again with returned object name and password
|
||||||
|
* The protocol for the java client, please refer to the sample code in main().
|
||||||
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: LdapConnectionHandler.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
* @version $Id: LdapConnectionHandler.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
|
@ -33,13 +62,15 @@ public class LdapConnectionHandler extends Thread
|
||||||
/**
|
/**
|
||||||
* Ldap Connection Handler
|
* Ldap Connection Handler
|
||||||
* @param socket server socket
|
* @param socket server socket
|
||||||
|
* @param model model
|
||||||
*/
|
*/
|
||||||
public LdapConnectionHandler(Socket socket)
|
public LdapConnectionHandler(Socket socket, MLdapProcessor model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_socket = socket;
|
m_socket = socket;
|
||||||
m_socket.setTcpNoDelay(true); // should not be required
|
m_socket.setTcpNoDelay(true); // should not be required
|
||||||
|
m_model = model;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +80,8 @@ public class LdapConnectionHandler extends Thread
|
||||||
|
|
||||||
/** Socket */
|
/** Socket */
|
||||||
private Socket m_socket = null;
|
private Socket m_socket = null;
|
||||||
|
/** Ldap Model */
|
||||||
|
private MLdapProcessor m_model = null;
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger (LdapConnectionHandler.class);
|
private static CLogger log = CLogger.getCLogger (LdapConnectionHandler.class);
|
||||||
|
|
||||||
|
@ -63,6 +96,9 @@ public class LdapConnectionHandler extends Thread
|
||||||
if (m_socket == null || m_socket.isClosed())
|
if (m_socket == null || m_socket.isClosed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
LdapMessage msg = new LdapMessage();
|
||||||
|
MLdapUser ldapUser = new MLdapUser();
|
||||||
|
LdapResult result = new LdapResult();
|
||||||
boolean activeSession = true;
|
boolean activeSession = true;
|
||||||
while (activeSession)
|
while (activeSession)
|
||||||
{
|
{
|
||||||
|
@ -72,21 +108,31 @@ public class LdapConnectionHandler extends Thread
|
||||||
byte[] buffer = new byte[512];
|
byte[] buffer = new byte[512];
|
||||||
int length = in.read(buffer, 0, 512);
|
int length = in.read(buffer, 0, 512);
|
||||||
|
|
||||||
LdapMessage msg = new LdapMessage (buffer, length);
|
// Decode the input message buffer
|
||||||
|
result.reset(msg, ldapUser);
|
||||||
|
msg.reset(result);
|
||||||
|
msg.decode(buffer, length);
|
||||||
if (msg.getOperation() == LdapMessage.UNBIND_REQUEST)
|
if (msg.getOperation() == LdapMessage.UNBIND_REQUEST)
|
||||||
{
|
{
|
||||||
activeSession = false;
|
|
||||||
out.close();
|
out.close();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Not unbind, so we can create a response
|
||||||
LdapResult result = new LdapResult ();
|
byte[] bytes = result.getResult(m_model);
|
||||||
byte[] bytes = result.bindResponse();
|
|
||||||
//
|
// Send the response back
|
||||||
out.write(bytes);
|
out.write(bytes);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
|
// If there's error or successfully authenticated the user,
|
||||||
|
// close the connection to avoid too many open connection
|
||||||
|
if (result.getDone())
|
||||||
|
{
|
||||||
|
out.close();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
} // while(activeSession)
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -115,4 +161,42 @@ public class LdapConnectionHandler extends Thread
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test using the java client.
|
||||||
|
* Ldap v3 won't need to do any bind, search, bind anymore.
|
||||||
|
* When new InitialLdapContext() is called, it will bind with the
|
||||||
|
* dn and password, the ldap server should be authenticate with it.
|
||||||
|
*
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
Hashtable<String,String> env = new Hashtable<String,String>();
|
||||||
|
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||||
|
// ldap://dc.compiere.org
|
||||||
|
env.put(Context.PROVIDER_URL, "ldap://10.104.139.160:389");
|
||||||
|
env.put(Context.SECURITY_AUTHENTICATION, "simple");
|
||||||
|
// Compiere server only support cn/o/ou, and cn should be the user id.
|
||||||
|
// Only one entry for cn.
|
||||||
|
env.put(Context.SECURITY_PRINCIPAL, "cn=cboss@compiere.org,o=GardenWorld,ou=LawnCare");
|
||||||
|
env.put(Context.SECURITY_CREDENTIALS, "carlboss");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Create the initial context
|
||||||
|
new InitialLdapContext(env, null);
|
||||||
|
// If not successfully authenticated, exception should be thrown
|
||||||
|
System.out.println("Successfully authenticated ...");
|
||||||
|
}
|
||||||
|
catch (AuthenticationException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} // main()
|
||||||
} // LdapConnectionHandler
|
} // LdapConnectionHandler
|
||||||
|
|
|
@ -10,12 +10,13 @@
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
* You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.ldap;
|
package org.compiere.ldap;
|
||||||
|
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
import com.sun.jndi.ldap.*;
|
import com.sun.jndi.ldap.*;
|
||||||
|
|
||||||
|
@ -27,139 +28,236 @@ import com.sun.jndi.ldap.*;
|
||||||
*/
|
*/
|
||||||
public class LdapMessage
|
public class LdapMessage
|
||||||
{
|
{
|
||||||
/**
|
static public final int BIND_REQUEST = 96;
|
||||||
* Ldap Message
|
static public final int BIND_RESPONSE = 97;
|
||||||
* @param data BER data
|
static public final int UNBIND_REQUEST = 98;
|
||||||
* @param length Ber data length
|
static public final int SEARCH_REQUEST = 99;
|
||||||
*/
|
static public final int SEARCH_REP_ENTRY = 100;
|
||||||
public LdapMessage (byte[] data, int length)
|
static public final int SEARCH_RES_RESULT = 101;
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
decode(data, length);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, data.toString(), e);
|
|
||||||
}
|
|
||||||
} // LdapMessage
|
|
||||||
|
|
||||||
/**
|
static public final int SIMPLE_AUTHENTICATION = 128;
|
||||||
LDAPMessage ::= SEQUENCE {
|
|
||||||
messageID MessageID,
|
|
||||||
protocolOp CHOICE {
|
|
||||||
bindRequest BindRequest,
|
|
||||||
bindResponse BindResponse,
|
|
||||||
unbindRequest UnbindRequest,
|
|
||||||
searchRequest SearchRequest,
|
|
||||||
searchResEntry SearchResultEntry,
|
|
||||||
searchResDone SearchResultDone,
|
|
||||||
searchResRef SearchResultReference,
|
|
||||||
modifyRequest ModifyRequest,
|
|
||||||
modifyResponse ModifyResponse,
|
|
||||||
addRequest AddRequest,
|
|
||||||
addResponse AddResponse,
|
|
||||||
delRequest DelRequest,
|
|
||||||
delResponse DelResponse,
|
|
||||||
modDNRequest ModifyDNRequest,
|
|
||||||
modDNResponse ModifyDNResponse,
|
|
||||||
compareRequest CompareRequest,
|
|
||||||
compareResponse CompareResponse,
|
|
||||||
abandonRequest AbandonRequest,
|
|
||||||
extendedReq ExtendedRequest,
|
|
||||||
extendedResp ExtendedResponse },
|
|
||||||
controls [0] Controls OPTIONAL }
|
|
||||||
**/
|
|
||||||
|
|
||||||
static public final int BIND_REQUEST = 0;
|
static public final int FILTER_AND = 160;
|
||||||
static public final int BIND_RESPONSE = 1;
|
static public final int FILTER_OR = 161;
|
||||||
static public final int UNBIND_REQUEST = 2;
|
static public final int FILTER_NOT = 162;
|
||||||
static public final int SEARCH_REQUEST = 3;
|
static public final int FILTER_EQUALITYMATCH = 163;
|
||||||
static public final int SEARCH_RESENTRY = 4;
|
|
||||||
static public final int SEARCH_RESDONE = 5;
|
|
||||||
static public final int MODIFY_REQUEST = 6;
|
|
||||||
static public final int MODIFY_RESPONSE = 7;
|
|
||||||
static public final int ADD_REQUEST = 8;
|
|
||||||
static public final int ADD_RESPONSE = 9;
|
|
||||||
static public final int DEL_REQUEST = 10;
|
|
||||||
static public final int DEL_RESPONSE = 11;
|
|
||||||
static public final int MODDN_REQUEST = 12;
|
|
||||||
static public final int MODDN_RESPONSE = 13;
|
|
||||||
static public final int COMPARE_REQUEST = 14;
|
|
||||||
static public final int COMPARE_RESPONSE = 15;
|
|
||||||
static public final int ABANDON_REQUEST = 16;
|
|
||||||
static public final int EXTENDED_REQUEST = 17;
|
|
||||||
static public final int EXTENDED_RESPONSE = 18;
|
|
||||||
|
|
||||||
static public final int[] PROTOCOL_OP = {
|
|
||||||
BIND_REQUEST, BIND_RESPONSE, UNBIND_REQUEST,
|
|
||||||
SEARCH_REQUEST, SEARCH_RESENTRY, SEARCH_RESDONE,
|
|
||||||
MODIFY_REQUEST, MODIFY_RESPONSE, ADD_REQUEST, ADD_RESPONSE,
|
|
||||||
DEL_REQUEST, DEL_RESPONSE, MODDN_REQUEST, MODDN_RESPONSE,
|
|
||||||
COMPARE_REQUEST, COMPARE_RESPONSE, ABANDON_REQUEST,
|
|
||||||
EXTENDED_REQUEST, EXTENDED_RESPONSE};
|
|
||||||
|
|
||||||
|
static public final int SEQUENCE = 48;
|
||||||
|
|
||||||
|
/** Decoder */
|
||||||
|
private BerDecoder decoder = null;
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger (LdapMessage.class);
|
private static CLogger log = CLogger.getCLogger (LdapMessage.class);
|
||||||
/** Protocol Operation */
|
/** Protocol Operation */
|
||||||
private int m_protocolOp = -1;
|
private int m_protocolOp = -1;
|
||||||
|
/** Message Id needed for the reply message */
|
||||||
|
private int msgId;
|
||||||
|
/** Distinguished name */
|
||||||
|
private String dn = null;
|
||||||
|
/** Organization */
|
||||||
|
private String org = null;
|
||||||
|
/** Organization unit */
|
||||||
|
private String orgUnit = null;
|
||||||
|
/** User Id */
|
||||||
|
private String userId = null;
|
||||||
|
/** Password */
|
||||||
|
private String passwd = null;
|
||||||
|
/** base Object */
|
||||||
|
private String baseObj = null;
|
||||||
|
/** LdapResult object to hold if there's any error during parsing */
|
||||||
|
private LdapResult result = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ldap Message
|
||||||
|
*/
|
||||||
|
public LdapMessage()
|
||||||
|
{
|
||||||
|
} // LdapMessage
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset all the attributes
|
||||||
|
*/
|
||||||
|
public void reset(LdapResult result)
|
||||||
|
{
|
||||||
|
this.result = result;
|
||||||
|
decoder = null;
|
||||||
|
m_protocolOp = -1;
|
||||||
|
msgId = -1;
|
||||||
|
dn = null;
|
||||||
|
org = null;
|
||||||
|
orgUnit = null;
|
||||||
|
userId = null;
|
||||||
|
passwd = null;
|
||||||
|
baseObj = null;
|
||||||
|
|
||||||
|
} // reset()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode Message
|
* Decode Message
|
||||||
* @param data data
|
* @param data input buffer
|
||||||
* @param length length
|
* @param length buffer size
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
private void decode (byte[] data, int length) throws Exception
|
public void decode(byte[] data, int length)
|
||||||
{
|
{
|
||||||
BerDecoder decoder = new BerDecoder(data, 0, length);
|
try
|
||||||
int left = decoder.bytesLeft();
|
{
|
||||||
int pos = decoder.getParsePosition();
|
// Create the decoder
|
||||||
//
|
decoder = new BerDecoder(data, 0, length);
|
||||||
int seq = decoder.parseSeq(null);
|
}
|
||||||
left = decoder.bytesLeft();
|
catch (Exception e)
|
||||||
pos = decoder.getParsePosition();
|
{
|
||||||
//
|
log.log(Level.SEVERE, data.toString(), e);
|
||||||
int messageID = decoder.parseInt();
|
return;
|
||||||
left = decoder.bytesLeft();
|
}
|
||||||
pos = decoder.getParsePosition();
|
|
||||||
//
|
try
|
||||||
int peek = decoder.peekByte();
|
{
|
||||||
m_protocolOp = decoder.parseSeq(PROTOCOL_OP);
|
// Parse the message envelope
|
||||||
m_protocolOp -= Ber.ASN_APPLICATION;
|
decoder.parseSeq(null);
|
||||||
if (m_protocolOp - Ber.ASN_CONSTRUCTOR >= 0)
|
|
||||||
m_protocolOp -= Ber.ASN_CONSTRUCTOR;
|
// Parse message Id
|
||||||
left = decoder.bytesLeft();
|
msgId = decoder.parseInt();
|
||||||
pos = decoder.getParsePosition();
|
|
||||||
|
// Parse the operation protocol
|
||||||
|
m_protocolOp = decoder.parseSeq(null);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Payload
|
// Payload
|
||||||
if (m_protocolOp == BIND_REQUEST)
|
if (m_protocolOp == BIND_REQUEST)
|
||||||
{
|
handleBind();
|
||||||
int version = decoder.parseInt();
|
|
||||||
left = decoder.bytesLeft();
|
|
||||||
pos = decoder.getParsePosition();
|
|
||||||
//
|
|
||||||
byte[] dn = decoder.parseOctetString(Ber.ASN_OCTET_STR, null);
|
|
||||||
left = decoder.bytesLeft();
|
|
||||||
pos = decoder.getParsePosition();
|
|
||||||
//
|
|
||||||
byte[] authentification = decoder.parseOctetString(Ber.ASN_CONTEXT, null);
|
|
||||||
left = decoder.bytesLeft();
|
|
||||||
pos = decoder.getParsePosition();
|
|
||||||
//
|
|
||||||
log.info("#" + messageID + ": bind - version=" + version + ", dn=" + new String(dn)
|
|
||||||
+ ", auth=" + new String (authentification));
|
|
||||||
}
|
|
||||||
else if (m_protocolOp == UNBIND_REQUEST)
|
else if (m_protocolOp == UNBIND_REQUEST)
|
||||||
log.info("#" + messageID + ": unbind");
|
log.info("#" + msgId + ": unbind");
|
||||||
else
|
else if (m_protocolOp == SEARCH_REQUEST)
|
||||||
|
handleSearch();
|
||||||
|
else // Only supoort BIND, UNBIND and SEARCH
|
||||||
{
|
{
|
||||||
log.warning("#" + messageID + ": Unknown Op + " + m_protocolOp);
|
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||||
|
result.setErrorString(": Unsupported Request");
|
||||||
|
log.warning("#" + msgId + ": Unknown Op + " + m_protocolOp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||||
|
log.log(Level.SEVERE, "", ex);
|
||||||
}
|
}
|
||||||
} // decode
|
} // decode
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encode the search request message
|
||||||
|
*/
|
||||||
|
private void handleSearch()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Parse the base Object
|
||||||
|
baseObj = decoder.parseString(true);
|
||||||
|
parseDN(baseObj);
|
||||||
|
|
||||||
|
decoder.parseEnumeration(); // scope
|
||||||
|
decoder.parseEnumeration(); // derefAliases
|
||||||
|
decoder.parseInt(); // sizeLimit
|
||||||
|
decoder.parseInt(); // timeLimit
|
||||||
|
decoder.parseBoolean(); // typeOnly
|
||||||
|
|
||||||
|
boolean equalityFilter = false;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int filter = decoder.parseSeq(null); //Filter
|
||||||
|
if (filter == FILTER_EQUALITYMATCH)
|
||||||
|
{
|
||||||
|
decoder.parseString(true);
|
||||||
|
userId = decoder.parseString(true);
|
||||||
|
equalityFilter = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (filter == FILTER_AND)
|
||||||
|
decoder.parseStringWithTag(135, true, null);
|
||||||
|
else if (filter == SEQUENCE)
|
||||||
|
break;
|
||||||
|
} // while true
|
||||||
|
|
||||||
|
if (!equalityFilter) // Didn't find the it
|
||||||
|
{
|
||||||
|
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||||
|
result.setErrorString("Can't can't Filter - EqualityMatch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "", ex);
|
||||||
|
}
|
||||||
|
} // handleSearch()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encode the bind request message
|
||||||
|
*/
|
||||||
|
private void handleBind()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Parse LDAP version; only support v3
|
||||||
|
int version = decoder.parseInt();
|
||||||
|
if (version != 3)
|
||||||
|
{
|
||||||
|
result.setErrorNo(LdapResult.LDAP_PROTOCOL_ERROR);
|
||||||
|
result.setErrorString("Unsupported LDAP version");
|
||||||
|
log.info("#" + msgId + ": unsupported LDAP version - " + version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse DN
|
||||||
|
dn = decoder.parseString(true);
|
||||||
|
|
||||||
|
// Peek on AuthenticationChoice; only support simple authentication
|
||||||
|
int auth = decoder.peekByte();
|
||||||
|
if (auth != SIMPLE_AUTHENTICATION) // 0x80 - simple authentication
|
||||||
|
{
|
||||||
|
result.setErrorNo(LdapResult.LDAP_AUTH_METHOD_NOT_SUPPORTED);
|
||||||
|
log.info("#" + msgId + ": unsupported authentication method - " + auth);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is simple authentication, get the authentication string
|
||||||
|
passwd = decoder.parseStringWithTag(SIMPLE_AUTHENTICATION, true, null);
|
||||||
|
if (passwd != null && passwd.length() > 0)
|
||||||
|
{
|
||||||
|
parseDN(dn);
|
||||||
|
if (userId == null || userId.length() <= 0)
|
||||||
|
{
|
||||||
|
result.setErrorNo(LdapResult.LDAP_NO_SUCH_OBJECT);
|
||||||
|
result.setErrorString(": \"cn\" not defined");
|
||||||
|
log.info("#" + msgId + ": \"cn\" not defined");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log the information
|
||||||
|
log.info("#" + msgId + ": bind - version=" + version + ", userId=" + userId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "", ex);
|
||||||
|
}
|
||||||
|
} // handleBind()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse the DN to find user id, organization and organization unit
|
||||||
|
*/
|
||||||
|
private void parseDN(String dName)
|
||||||
|
{
|
||||||
|
String[] dnArray = dName.split(",");
|
||||||
|
for (int i = 0; i < dnArray.length; i++)
|
||||||
|
{
|
||||||
|
if (dnArray[i].startsWith("cn="))
|
||||||
|
userId = dnArray[i].split("=")[1];
|
||||||
|
else if (dnArray[i].startsWith("o="))
|
||||||
|
org = dnArray[i].split("=")[1];
|
||||||
|
else if (dnArray[i].startsWith("ou="))
|
||||||
|
orgUnit = dnArray[i].split("=")[1];
|
||||||
|
}
|
||||||
|
} // parseDN()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Operation Code
|
* Get Operation Code
|
||||||
* @return protocolOp
|
* @return protocolOp
|
||||||
|
@ -169,4 +267,66 @@ public class LdapMessage
|
||||||
return m_protocolOp;
|
return m_protocolOp;
|
||||||
} // getOperation
|
} // getOperation
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get message id
|
||||||
|
* @return msgId
|
||||||
|
*/
|
||||||
|
public int getMsgId()
|
||||||
|
{
|
||||||
|
return msgId;
|
||||||
|
} // getMsgId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get DN
|
||||||
|
* @return dn
|
||||||
|
*/
|
||||||
|
public String getDN()
|
||||||
|
{
|
||||||
|
return dn;
|
||||||
|
} // getDN()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User Id
|
||||||
|
* @return userId
|
||||||
|
*/
|
||||||
|
public String getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
} // getUserId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get User passwod
|
||||||
|
* @return passwd
|
||||||
|
*/
|
||||||
|
public String getUserPasswd()
|
||||||
|
{
|
||||||
|
return passwd;
|
||||||
|
} // getUserPasswd()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get base object
|
||||||
|
* @return baseObj
|
||||||
|
*/
|
||||||
|
public String getBaseObj()
|
||||||
|
{
|
||||||
|
return baseObj;
|
||||||
|
} // getBaseObj()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get organization
|
||||||
|
* @return org
|
||||||
|
*/
|
||||||
|
public String getOrg()
|
||||||
|
{
|
||||||
|
return org;
|
||||||
|
} // getOrg()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get organization unit
|
||||||
|
* @return orgUnit
|
||||||
|
*/
|
||||||
|
public String getOrgUnit()
|
||||||
|
{
|
||||||
|
return orgUnit;
|
||||||
|
} // getOrgUnit()
|
||||||
} // LdapMessage
|
} // LdapMessage
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
* You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.ldap;
|
package org.compiere.ldap;
|
||||||
|
|
||||||
|
@ -19,9 +19,7 @@ import java.net.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import javax.naming.ldap.*;
|
|
||||||
import org.compiere.*;
|
import org.compiere.*;
|
||||||
import org.compiere.ldap.*;
|
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.server.*;
|
import org.compiere.server.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
@ -38,19 +36,16 @@ public class LdapProcessor extends AdempiereServer
|
||||||
* Ldap Processor (Server)
|
* Ldap Processor (Server)
|
||||||
* @param model Ldap Model
|
* @param model Ldap Model
|
||||||
*/
|
*/
|
||||||
public LdapProcessor (LdapProcessorModel model)
|
public LdapProcessor (MLdapProcessor model)
|
||||||
{
|
{
|
||||||
super (model, 300);
|
super (model, 300);
|
||||||
m_model = model;
|
m_model = model;
|
||||||
init();
|
|
||||||
} // LdapProcessor
|
} // LdapProcessor
|
||||||
|
|
||||||
/** The Concrete Model */
|
/** The Concrete Model */
|
||||||
private LdapProcessorModel m_model = null;
|
private MLdapProcessor m_model = null;
|
||||||
/** Last Summary */
|
/** Last Summary */
|
||||||
private StringBuffer m_summary = new StringBuffer();
|
private StringBuffer m_summary = new StringBuffer();
|
||||||
/** Client info */
|
|
||||||
private MClient m_client = null;
|
|
||||||
/** Server Socket */
|
/** Server Socket */
|
||||||
private ServerSocket m_serverSocket = null;
|
private ServerSocket m_serverSocket = null;
|
||||||
/** Counter */
|
/** Counter */
|
||||||
|
@ -87,7 +82,8 @@ public class LdapProcessor extends AdempiereServer
|
||||||
{
|
{
|
||||||
Socket socket = m_serverSocket.accept(); // waits for connection
|
Socket socket = m_serverSocket.accept(); // waits for connection
|
||||||
log.log(Level.FINE, "Connection on Port=" + m_model.getLdapPort());
|
log.log(Level.FINE, "Connection on Port=" + m_model.getLdapPort());
|
||||||
LdapConnectionHandler handler = new LdapConnectionHandler (socket);
|
LdapConnectionHandler handler =
|
||||||
|
new LdapConnectionHandler (socket, m_model);
|
||||||
handler.start();
|
handler.start();
|
||||||
m_counter++;
|
m_counter++;
|
||||||
}
|
}
|
||||||
|
@ -98,24 +94,19 @@ public class LdapProcessor extends AdempiereServer
|
||||||
m_summary.append(e.toString());
|
m_summary.append(e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_summary.append ("; ")
|
||||||
|
.append (m_model.getInfo());
|
||||||
|
|
||||||
|
int no = m_model.deleteLog();
|
||||||
|
m_summary.append("; Logs deleted=").append(no);
|
||||||
|
//
|
||||||
|
MLdapProcessorLog pLog = new MLdapProcessorLog(m_model, m_summary.toString());
|
||||||
|
pLog.setReference("#" + String.valueOf(p_runCount)
|
||||||
|
+ " - " + TimeUtil.formatElapsed(new Timestamp(p_startWork)));
|
||||||
|
pLog.save();
|
||||||
|
|
||||||
} // doWork
|
} // doWork
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize
|
|
||||||
*/
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InitialLdapContext lctx = new InitialLdapContext();
|
|
||||||
// lctx.setRequestControls(critModCtls);
|
|
||||||
// lctx.modifyAttributes(name, mods);
|
|
||||||
Control[] respCtls = lctx.getResponseControls();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
} //
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Server Info
|
* Get Server Info
|
||||||
|
@ -124,7 +115,8 @@ public class LdapProcessor extends AdempiereServer
|
||||||
public String getServerInfo()
|
public String getServerInfo()
|
||||||
{
|
{
|
||||||
return "#" + p_runCount + " - Last=" + m_summary.toString()
|
return "#" + p_runCount + " - Last=" + m_summary.toString()
|
||||||
+ "; Counter=" + m_counter;
|
+ "; Counter=" + m_counter
|
||||||
|
+ "; " + m_model.getInfo();
|
||||||
} // getServerInfo
|
} // getServerInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +126,7 @@ public class LdapProcessor extends AdempiereServer
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
Adempiere.startup(true);
|
Adempiere.startup(true);
|
||||||
new LdapProcessor(new LdapProcessorModel(new Properties())).doWork();
|
new LdapProcessor(new MLdapProcessor(new Properties(), 0, null)).doWork();
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
} // LdapProcessor
|
} // LdapProcessor
|
||||||
|
|
|
@ -1,158 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution
|
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved.
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms version 2 of the GNU General Public License as published
|
|
||||||
* by the Free Software Foundation. This program is distributed in the hope
|
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
* See the GNU General Public License for more details.
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
|
||||||
* You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
|
|
||||||
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
|
|
||||||
*****************************************************************************/
|
|
||||||
package org.compiere.ldap;
|
|
||||||
|
|
||||||
import java.sql.*;
|
|
||||||
import java.util.*;
|
|
||||||
import org.compiere.model.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interim LDAP Server Model
|
|
||||||
*
|
|
||||||
* @author Jorg Janke
|
|
||||||
* @version $Id: LdapProcessorModel.java,v 1.1 2006/10/09 00:23:16 jjanke Exp $
|
|
||||||
*/
|
|
||||||
public class LdapProcessorModel implements AdempiereProcessor
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Ldap Processor Model
|
|
||||||
* @param ctx context
|
|
||||||
*/
|
|
||||||
public LdapProcessorModel (Properties ctx)
|
|
||||||
{
|
|
||||||
m_ctx = ctx;
|
|
||||||
}
|
|
||||||
// Properties
|
|
||||||
private Properties m_ctx = null;
|
|
||||||
|
|
||||||
private Timestamp m_dateNextRun;
|
|
||||||
private Timestamp m_dateLastRun;
|
|
||||||
|
|
||||||
|
|
||||||
public int getLdapPort()
|
|
||||||
{
|
|
||||||
return 389;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* String Representation
|
|
||||||
* @return info
|
|
||||||
*/
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuffer sb = new StringBuffer (getName());
|
|
||||||
sb.append (";Port=").append (getLdapPort());
|
|
||||||
return sb.toString ();
|
|
||||||
} // toString
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* getAD_Client_ID
|
|
||||||
* @see org.compiere.model.AdempiereProcessor#getAD_Client_ID()
|
|
||||||
* @return 0
|
|
||||||
*/
|
|
||||||
public int getAD_Client_ID()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* getName
|
|
||||||
* @see org.compiere.model.AdempiereProcessor#getName()
|
|
||||||
* @return name
|
|
||||||
*/
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return "Adempiere LDAP Server";
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* getDescription
|
|
||||||
* @see org.compiere.model.AdempiereProcessor#getDescription()
|
|
||||||
* @return -
|
|
||||||
*/
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return "-";
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get Ctx
|
|
||||||
* @return context
|
|
||||||
*/
|
|
||||||
public Properties getCtx()
|
|
||||||
{
|
|
||||||
return m_ctx;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* GetFrequencyType
|
|
||||||
* @see org.compiere.model.AdempiereProcessor#getFrequencyType()
|
|
||||||
* @return min
|
|
||||||
*/
|
|
||||||
public String getFrequencyType()
|
|
||||||
{
|
|
||||||
return MRequestProcessor.FREQUENCYTYPE_Minute;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* getFrequency
|
|
||||||
* @see org.compiere.model.AdempiereProcessor#getFrequency()
|
|
||||||
* @return 1
|
|
||||||
*/
|
|
||||||
public int getFrequency()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Unique Server ID
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
public String getServerID()
|
|
||||||
{
|
|
||||||
return "Ldap";
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getDateNextRun(boolean requery)
|
|
||||||
{
|
|
||||||
return m_dateNextRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDateNextRun(Timestamp dateNextWork)
|
|
||||||
{
|
|
||||||
m_dateNextRun = dateNextWork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Timestamp getDateLastRun()
|
|
||||||
{
|
|
||||||
return m_dateLastRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDateLastRun(Timestamp dateLastRun)
|
|
||||||
{
|
|
||||||
m_dateLastRun = dateLastRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean save()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AdempiereProcessorLog[] getLogs()
|
|
||||||
{
|
|
||||||
return new AdempiereProcessorLog[0];
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,15 +10,15 @@
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
||||||
* You may reach us at: ComPiere, Inc. - http://www.adempiere.org/license.html
|
* You may reach us at: ComPiere, Inc. - http://www.compiere.org/license.html
|
||||||
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@adempiere.org
|
* 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA or info@compiere.org
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.ldap;
|
package org.compiere.ldap;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
import org.compiere.model.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
import com.sun.jndi.ldap.*;
|
import com.sun.jndi.ldap.BerEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ldap Wire Response
|
* Ldap Wire Response
|
||||||
|
@ -28,120 +28,278 @@ import com.sun.jndi.ldap.*;
|
||||||
*/
|
*/
|
||||||
public class LdapResult
|
public class LdapResult
|
||||||
{
|
{
|
||||||
|
/** LdapMesssage */
|
||||||
public LdapResult()
|
private LdapMessage ldapMsg = null;
|
||||||
{
|
|
||||||
super ();
|
|
||||||
} // LdapResult
|
|
||||||
|
|
||||||
/**
|
|
||||||
LDAPResult ::= SEQUENCE {
|
|
||||||
resultCode ENUMERATED {
|
|
||||||
success (0),
|
|
||||||
operationsError (1),
|
|
||||||
protocolError (2),
|
|
||||||
timeLimitExceeded (3),
|
|
||||||
sizeLimitExceeded (4),
|
|
||||||
compareFalse (5),
|
|
||||||
compareTrue (6),
|
|
||||||
|
|
||||||
authMethodNotSupported (7),
|
|
||||||
strongAuthRequired (8),
|
|
||||||
-- 9 reserved --
|
|
||||||
referral (10), -- new
|
|
||||||
adminLimitExceeded (11), -- new
|
|
||||||
unavailableCriticalExtension (12), -- new
|
|
||||||
confidentialityRequired (13), -- new
|
|
||||||
saslBindInProgress (14), -- new
|
|
||||||
noSuchAttribute (16),
|
|
||||||
undefinedAttributeType (17),
|
|
||||||
inappropriateMatching (18),
|
|
||||||
constraintViolation (19),
|
|
||||||
attributeOrValueExists (20),
|
|
||||||
invalidAttributeSyntax (21),
|
|
||||||
noSuchObject (32),
|
|
||||||
aliasProblem (33),
|
|
||||||
invalidDNSyntax (34),
|
|
||||||
-- 35 reserved for undefined isLeaf --
|
|
||||||
aliasDereferencingProblem (36),
|
|
||||||
-- 37-47 unused --
|
|
||||||
inappropriateAuthentication (48),
|
|
||||||
invalidCredentials (49),
|
|
||||||
insufficientAccessRights (50),
|
|
||||||
busy (51),
|
|
||||||
unavailable (52),
|
|
||||||
unwillingToPerform (53),
|
|
||||||
loopDetect (54),
|
|
||||||
-- 55-63 unused --
|
|
||||||
namingViolation (64),
|
|
||||||
objectClassViolation (65),
|
|
||||||
notAllowedOnNonLeaf (66),
|
|
||||||
notAllowedOnRDN (67),
|
|
||||||
entryAlreadyExists (68),
|
|
||||||
objectClassModsProhibited (69),
|
|
||||||
-- 70 reserved for CLDAP --
|
|
||||||
affectsMultipleDSAs (71), -- new
|
|
||||||
-- 72-79 unused --
|
|
||||||
other (80) },
|
|
||||||
-- 81-90 reserved for APIs --
|
|
||||||
matchedDN LDAPDN,
|
|
||||||
errorMessage LDAPString,
|
|
||||||
referral [3] Referral OPTIONAL }
|
|
||||||
**/
|
|
||||||
|
|
||||||
/** Encoder */
|
/** Encoder */
|
||||||
private BerEncoder m_encoder = new BerEncoder();
|
private BerEncoder m_encoder = null;
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger log = CLogger.getCLogger (LdapResult.class);
|
private static CLogger log = CLogger.getCLogger (LdapResult.class);
|
||||||
|
/** Error number */
|
||||||
|
private int errNo = LDAP_SUCCESS;
|
||||||
|
/** Error String */
|
||||||
|
private String errStr = "";
|
||||||
|
/** LdapUser */
|
||||||
|
private MLdapUser ldapUser = null;
|
||||||
|
/** disconnect to client */
|
||||||
|
private boolean disconnect = false;
|
||||||
|
|
||||||
|
public LdapResult ()
|
||||||
|
{
|
||||||
|
} // LdapResult
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reset the attributes
|
||||||
|
*/
|
||||||
|
public void reset(LdapMessage ldapMsg, MLdapUser ldapUser)
|
||||||
|
{
|
||||||
|
this.ldapMsg = ldapMsg;
|
||||||
|
m_encoder = new BerEncoder();
|
||||||
|
errNo = LDAP_SUCCESS;
|
||||||
|
errStr = "";
|
||||||
|
this.ldapUser = ldapUser;
|
||||||
|
} // reset()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind Response
|
* Get the response according to the request message
|
||||||
|
* @param model model
|
||||||
* @return reponse
|
* @return reponse
|
||||||
*/
|
*/
|
||||||
public byte[] bindResponse()
|
public byte[] getResult(MLdapProcessor model)
|
||||||
{
|
{
|
||||||
|
if (errNo != LDAP_SUCCESS)
|
||||||
|
{
|
||||||
|
generateResult("",
|
||||||
|
((ldapMsg.getOperation()==LdapMessage.BIND_REQUEST)?
|
||||||
|
LdapMessage.BIND_RESPONSE:LdapMessage.SEARCH_RES_RESULT),
|
||||||
|
errNo, ldapErrorMessage[errNo] + errStr);
|
||||||
|
m_encoder.getTrimmedBuf();
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
/**
|
String usrId = ldapMsg.getUserId();
|
||||||
m_encoder.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
|
String o = ldapMsg.getOrg();
|
||||||
for (int i = 0; i < sortKeys.length; i++) {
|
String ou = ldapMsg.getOrgUnit();
|
||||||
ber.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
|
|
||||||
ber.encodeString(sortKeys[i].getAttributeID(), true); // v3
|
// Adding the Application 1 Sequence
|
||||||
if ((matchingRule = sortKeys[i].getMatchingRuleID()) != null) {
|
if (ldapMsg.getOperation() == LdapMessage.BIND_REQUEST)
|
||||||
ber.encodeString(matchingRule, (Ber.ASN_CONTEXT | 0), true);
|
{
|
||||||
}
|
String pwd = ldapMsg.getUserPasswd();
|
||||||
if (! sortKeys[i].isAscending()) {
|
if (pwd == null || pwd.length() <= 0)
|
||||||
ber.encodeBoolean(true, (Ber.ASN_CONTEXT | 1));
|
{
|
||||||
}
|
// 1st anonymous bind
|
||||||
ber.endSeq();
|
generateResult(ldapMsg.getDN(), LdapMessage.BIND_RESPONSE,
|
||||||
}
|
LDAP_SUCCESS, null);
|
||||||
*/
|
|
||||||
// payload
|
|
||||||
m_encoder.beginSeq(Ber.ASN_APPLICATION | LdapMessage.BIND_RESPONSE);
|
|
||||||
// Response
|
|
||||||
m_encoder.encodeInt(0); // success
|
|
||||||
m_encoder.encodeOctetString("cn=testCN".getBytes(), 0); // matched DN
|
|
||||||
m_encoder.encodeOctetString("".getBytes(), 0); // error mag
|
|
||||||
// referral
|
|
||||||
// sasl
|
|
||||||
//
|
|
||||||
m_encoder.endSeq();
|
|
||||||
log.info("Success");
|
log.info("Success");
|
||||||
|
return m_encoder.getTrimmedBuf();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Authenticate with Compiere data
|
||||||
|
if (ldapUser.getUserId() == null)
|
||||||
|
{ // Try to authenticate on the 1st bind, must be java client
|
||||||
|
ldapUser.reset();
|
||||||
|
model.authenticate(ldapUser, usrId, o, ou);
|
||||||
|
if (ldapUser.getErrorMsg() != null)
|
||||||
|
{ // Failed to authenticated with compiere
|
||||||
|
errNo = LDAP_NO_SUCH_OBJECT;
|
||||||
|
generateResult(ldapMsg.getBaseObj(), LdapMessage.SEARCH_RES_RESULT,
|
||||||
|
LDAP_NO_SUCH_OBJECT,
|
||||||
|
ldapErrorMessage[LDAP_NO_SUCH_OBJECT] + ldapUser.getErrorMsg());
|
||||||
|
log.info("Failed");
|
||||||
|
return m_encoder.getTrimmedBuf();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check to see if the input passwd is match to the one
|
||||||
|
// in compiere database
|
||||||
|
if (usrId.compareTo(ldapUser.getUserId()) == 0 &&
|
||||||
|
pwd.compareTo(ldapUser.getPassword()) == 0)
|
||||||
|
{ // Successfully authenticated
|
||||||
|
generateResult("", LdapMessage.BIND_RESPONSE,
|
||||||
|
LDAP_SUCCESS, null);
|
||||||
|
// Close the connection to client since most of the client
|
||||||
|
// application might cache the connection but we can't afford
|
||||||
|
// to have too many such client connection
|
||||||
|
disconnect = true;
|
||||||
|
log.info("Success");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Unsuccessfully authenticated
|
||||||
|
errNo = LDAP_INAPPROPRIATE_AUTHENTICATION;
|
||||||
|
generateResult("", LdapMessage.BIND_RESPONSE,
|
||||||
|
LDAP_INAPPROPRIATE_AUTHENTICATION,
|
||||||
|
ldapErrorMessage[LDAP_INAPPROPRIATE_AUTHENTICATION]);
|
||||||
|
log.info("Failed : " + ldapErrorMessage[LDAP_INAPPROPRIATE_AUTHENTICATION]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ldapMsg.getOperation() == LdapMessage.SEARCH_REQUEST)
|
||||||
|
{
|
||||||
|
// Authenticate with compiere database
|
||||||
|
ldapUser.reset();
|
||||||
|
model.authenticate(ldapUser, usrId, o, ou);
|
||||||
|
if (ldapUser.getErrorMsg() != null)
|
||||||
|
{
|
||||||
|
errNo = LDAP_NO_SUCH_OBJECT;
|
||||||
|
generateResult(ldapMsg.getBaseObj(), LdapMessage.SEARCH_RES_RESULT,
|
||||||
|
LDAP_NO_SUCH_OBJECT,
|
||||||
|
ldapErrorMessage[LDAP_NO_SUCH_OBJECT] + ldapUser.getErrorMsg());
|
||||||
|
log.info("Failed");
|
||||||
|
return m_encoder.getTrimmedBuf();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_encoder.beginSeq(48); // Hard coded here for Envelope header
|
||||||
|
m_encoder.encodeInt(ldapMsg.getMsgId());
|
||||||
|
m_encoder.beginSeq(LdapMessage.SEARCH_REP_ENTRY); // Application 4
|
||||||
|
m_encoder.encodeString("cn="+ldapMsg.getUserId(), true); // this should be object name
|
||||||
|
// not going to put in any attributes for this
|
||||||
|
m_encoder.beginSeq(48);
|
||||||
|
m_encoder.endSeq();
|
||||||
|
m_encoder.endSeq();
|
||||||
|
m_encoder.endSeq();
|
||||||
|
|
||||||
|
// SearchResultDone Application 5 for bind
|
||||||
|
// Result 0 = success
|
||||||
|
// No error message
|
||||||
|
generateResult(ldapMsg.getBaseObj(), LdapMessage.SEARCH_RES_RESULT,
|
||||||
|
LDAP_SUCCESS, null);
|
||||||
|
log.info("Success");
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_encoder.getTrimmedBuf();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "", e);
|
log.log(Level.SEVERE, "", e);
|
||||||
}
|
}
|
||||||
return getResult();
|
|
||||||
|
return m_encoder.getTrimmedBuf();
|
||||||
} // bindResponse
|
} // bindResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get BER Result as byte array
|
* Generate LDAPResult
|
||||||
* @return byte array
|
* @param dn Distinguished Name
|
||||||
|
* @param resultProtocol Result protocol/operation code
|
||||||
|
* @param resultCode Result code
|
||||||
|
* @param errMsg Error Message
|
||||||
|
* @return reponse
|
||||||
*/
|
*/
|
||||||
public byte[] getResult()
|
private void generateResult(String dn, int resultProtocol,
|
||||||
|
int resultCode, String errMsg)
|
||||||
{
|
{
|
||||||
return m_encoder.getTrimmedBuf();
|
try
|
||||||
} // getResult
|
{
|
||||||
|
m_encoder.beginSeq(48); // Hard coded here for Envelope header
|
||||||
|
m_encoder.encodeInt(ldapMsg.getMsgId());
|
||||||
|
m_encoder.beginSeq(resultProtocol);
|
||||||
|
m_encoder.encodeInt(resultCode, 10); // Enumeration - 10
|
||||||
|
// Adding LDAPDN
|
||||||
|
m_encoder.encodeString(dn, true);
|
||||||
|
// Adding error message
|
||||||
|
m_encoder.encodeString((errMsg == null)?"":errMsg, true);
|
||||||
|
m_encoder.endSeq();
|
||||||
|
m_encoder.endSeq();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "", ex);
|
||||||
|
}
|
||||||
|
} // generateResult()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Should it be close the connection with client
|
||||||
|
*/
|
||||||
|
public boolean getDone()
|
||||||
|
{
|
||||||
|
if (errNo != LDAP_SUCCESS)
|
||||||
|
return true;
|
||||||
|
return disconnect;
|
||||||
|
} // getDone()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the error No
|
||||||
|
* @param errNo Error Number
|
||||||
|
*/
|
||||||
|
public void setErrorNo(int errNo)
|
||||||
|
{
|
||||||
|
this.errNo = errNo;
|
||||||
|
} // setErrorNo()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error No
|
||||||
|
* @return errNo Error Number
|
||||||
|
*/
|
||||||
|
public int getErrorNo()
|
||||||
|
{
|
||||||
|
return errNo;
|
||||||
|
} // getErrorNo()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the error String
|
||||||
|
* @param errStr Error String
|
||||||
|
*/
|
||||||
|
public void setErrorString(String errStr)
|
||||||
|
{
|
||||||
|
this.errStr = errStr;
|
||||||
|
} // setErrorStr()
|
||||||
|
|
||||||
|
static final int LDAP_SUCCESS = 0;
|
||||||
|
static final int LDAP_OPERATIONS_ERROR = 1;
|
||||||
|
static final int LDAP_PROTOCOL_ERROR = 2;
|
||||||
|
static final int LDAP_TIME_LIMIT_EXCEEDED = 3;
|
||||||
|
static final int LDAP_SIZE_LIMIT_EXCEEDED = 4;
|
||||||
|
static final int LDAP_COMPARE_FALSE = 5;
|
||||||
|
static final int LDAP_COMPARE_TRUE = 6;
|
||||||
|
static final int LDAP_AUTH_METHOD_NOT_SUPPORTED = 7;
|
||||||
|
static final int LDAP_STRONG_AUTH_REQUIRED = 8;
|
||||||
|
static final int LDAP_PARTIAL_RESULTS = 9;
|
||||||
|
static final int LDAP_REFERRAL = 10;
|
||||||
|
static final int LDAP_ADMIN_LIMIT_EXCEEDED = 11;
|
||||||
|
static final int LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12;
|
||||||
|
static final int LDAP_CONFIDENTIALITY_REQUIRED = 13;
|
||||||
|
static final int LDAP_SASL_BIND_IN_PROGRESS = 14;
|
||||||
|
static final int LDAP_NO_SUCH_ATTRIBUTE = 16;
|
||||||
|
static final int LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17;
|
||||||
|
static final int LDAP_INAPPROPRIATE_MATCHING = 18;
|
||||||
|
static final int LDAP_CONSTRAINT_VIOLATION = 19;
|
||||||
|
static final int LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20;
|
||||||
|
static final int LDAP_INVALID_ATTRIBUTE_SYNTAX = 21;
|
||||||
|
static final int LDAP_NO_SUCH_OBJECT = 32;
|
||||||
|
static final int LDAP_ALIAS_PROBLEM = 33;
|
||||||
|
static final int LDAP_INVALID_DN_SYNTAX = 34;
|
||||||
|
static final int LDAP_IS_LEAF = 35;
|
||||||
|
static final int LDAP_ALIAS_DEREFERENCING_PROBLEM = 36;
|
||||||
|
static final int LDAP_INAPPROPRIATE_AUTHENTICATION = 48;
|
||||||
|
static final int LDAP_INVALID_CREDENTIALS = 49;
|
||||||
|
static final int LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50;
|
||||||
|
static final int LDAP_BUSY = 51;
|
||||||
|
static final int LDAP_UNAVAILABLE = 52;
|
||||||
|
static final int LDAP_UNWILLING_TO_PERFORM = 53;
|
||||||
|
static final int LDAP_LOOP_DETECT = 54;
|
||||||
|
static final int LDAP_NAMING_VIOLATION = 64;
|
||||||
|
static final int LDAP_OBJECT_CLASS_VIOLATION = 65;
|
||||||
|
static final int LDAP_NOT_ALLOWED_ON_NON_LEAF = 66;
|
||||||
|
static final int LDAP_NOT_ALLOWED_ON_RDN = 67;
|
||||||
|
static final int LDAP_ENTRY_ALREADY_EXISTS = 68;
|
||||||
|
static final int LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69;
|
||||||
|
static final int LDAP_AFFECTS_MULTIPLE_DSAS = 71;
|
||||||
|
static final int LDAP_OTHER = 80;
|
||||||
|
static final String ldapErrorMessage[] = {
|
||||||
|
"Success", "Operations Error", "Protocol Error", "Timelimit Exceeded",
|
||||||
|
"Sizelimit Exceeded", "Compare False", "Compare True",
|
||||||
|
"Authentication Method Not Supported", "Strong Authentication Required", null,
|
||||||
|
"Referral", "Administrative Limit Exceeded", "Unavailable Critical Extension",
|
||||||
|
"Confidentiality Required", "SASL Bind In Progress", null, "No Such Attribute",
|
||||||
|
"Undefined Attribute Type", "Inappropriate Matching", "Constraint Violation",
|
||||||
|
"Attribute Or Value Exists", "Invalid Attribute Syntax", null, null, null,
|
||||||
|
null, null, null, null, null,null, null, "No Such Object", "Alias Problem",
|
||||||
|
"Invalid DN Syntax", null, "Alias Dereferencing Problem", null, null, null,
|
||||||
|
null, null, null, null, null, null, null, null, "Inappropriate Authentication",
|
||||||
|
"Invalid Credentials", "Insufficient Access Rights", "Busy", "Unavailable",
|
||||||
|
"Unwilling To Perform", "Loop Detect", null, null, null, null, null,
|
||||||
|
null, null, null, null, "Naming Violation", "Object Class Violation",
|
||||||
|
"Not Allowed On Non-leaf", "Not Allowed On RDN", "Entry Already Exists",
|
||||||
|
"Object Class Modifications Prohibited", null, "Affects Multiple DSAs", null,
|
||||||
|
null, null, null, null, null, null, null,"Other", null, null, null, null,
|
||||||
|
null, null, null, null, null,null
|
||||||
|
};
|
||||||
} // LdapResult
|
} // LdapResult
|
||||||
|
|
|
@ -49,8 +49,8 @@ public abstract class AdempiereServer extends Thread
|
||||||
return new AlertProcessor ((MAlertProcessor)model);
|
return new AlertProcessor ((MAlertProcessor)model);
|
||||||
if (model instanceof MScheduler)
|
if (model instanceof MScheduler)
|
||||||
return new Scheduler ((MScheduler)model);
|
return new Scheduler ((MScheduler)model);
|
||||||
if (model instanceof LdapProcessorModel)
|
if (model instanceof MLdapProcessor)
|
||||||
return new LdapProcessor((LdapProcessorModel)model);
|
return new LdapProcessor((MLdapProcessor)model);
|
||||||
//
|
//
|
||||||
throw new IllegalArgumentException("Unknown Processor");
|
throw new IllegalArgumentException("Unknown Processor");
|
||||||
} // create
|
} // create
|
||||||
|
|
|
@ -20,7 +20,6 @@ import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import org.compiere.*;
|
import org.compiere.*;
|
||||||
import org.compiere.ldap.*;
|
|
||||||
import org.compiere.model.*;
|
import org.compiere.model.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
import org.compiere.wf.*;
|
import org.compiere.wf.*;
|
||||||
|
@ -148,12 +147,15 @@ public class AdempiereServerMgr
|
||||||
m_servers.add(server);
|
m_servers.add(server);
|
||||||
}
|
}
|
||||||
// LDAP
|
// LDAP
|
||||||
LdapProcessorModel lp = new LdapProcessorModel(m_ctx);
|
MLdapProcessor[] ldapModels = MLdapProcessor.getActive(m_ctx);
|
||||||
|
for (int i = 0; i < ldapModels.length; i++)
|
||||||
|
{
|
||||||
|
MLdapProcessor lp = ldapModels[i];
|
||||||
AdempiereServer server = AdempiereServer.create(lp);
|
AdempiereServer server = AdempiereServer.create(lp);
|
||||||
server.start();
|
server.start();
|
||||||
server.setPriority(Thread.NORM_PRIORITY-2);
|
server.setPriority(Thread.NORM_PRIORITY-1);
|
||||||
m_servers.add(server);
|
m_servers.add(server);
|
||||||
|
}
|
||||||
|
|
||||||
log.fine("#" + noServers);
|
log.fine("#" + noServers);
|
||||||
return startAll();
|
return startAll();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
codebase = "$$context/adempiereHome"
|
codebase = "$$context/adempiereHome"
|
||||||
href = "$$context/adempiere.jnlp">
|
href = "$$context/adempiere.jnlp">
|
||||||
<information>
|
<information>
|
||||||
<title>Adempiere Client 3.1.1 $$context</title>
|
<title>Adempiere Client 3.1.2 $$context</title>
|
||||||
<vendor>ComPiere, Inc.</vendor>
|
<vendor>ComPiere, Inc.</vendor>
|
||||||
<homepage href = "http://www.adempiere.org"/>
|
<homepage href = "http://www.adempiere.org"/>
|
||||||
<offline-allowed/>
|
<offline-allowed/>
|
||||||
|
|
Loading…
Reference in New Issue