package com.davidwsappserverpackage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.Security;
import java.util.Properties;
import com.cordys.cpc.bsf.busobject.BSF;
import com.eibus.util.system.EIBProperties;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPJSSESecureSocketFactory;
import com.novell.ldap.LDAPSocketFactory;
public class CordysConfig {
static String LDAP_TO_SERVER = "thinkpad-PC.YT";
static String LDAP_TO_PORT = "6366";
static String LDAP_TO_USER = "cn=Directory Manager,o=mydomain.com";
static String LDAP_TO_PWD = "cordys";
public static String authenticatedUsersDn = "cn=authenticated users,cn=cordys,cn=defaultInst,o=mydomain.com";
public static String ownerOrgDn = "o=DOrg,cn=cordys,cn=defaultInst,o=mydomain.com";
public static String orgUserDn = "cn=organizational users,o=DOrg,cn=cordys,cn=defaultInst,o=mydomain.com";
public static String baseRole = "cn=everyoneInruizhong,cn=organizational roles,o=ruizhong,cn=cordys,cn=defaultInst,o=comac.intra";
public static String certifiName = "C:/Program Files/OpenText/OpenText Cordys/defaultInst/certificates/truststore/CordysTrustStore.jks";
private static LDAPConnection connection;
public static LDAPConnection getToLDAPConnection() {
if(connection != null && connection.isConnected()){
return connection;
}else{
connection = null;
}
try {
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("javax.net.ssl.trustStore", certifiName);
LDAPSocketFactory ssf = new LDAPJSSESecureSocketFactory();
LDAPConnection.setSocketFactory(ssf);
connection = new LDAPConnection();
connection.connect(LDAP_TO_SERVER, Integer.parseInt(LDAP_TO_PORT) );
connection.bind(LDAPConnection.LDAP_V3, LDAP_TO_USER, LDAP_TO_PWD.getBytes());
} catch (Exception e) {
System.out.println("ldap连接异常");
e.printStackTrace();
}
return connection;
}
public static LDAPConnection getInnerLDAPConnection()
{
return BSF.getLDAPDirectory().getConnection();
}
}
/*
This class has been generated by the Code Generator
*/
package com.davidwsappserverpackage;
import com.cordys.cpc.bsf.busobject.BSF;
import com.cordys.cpc.bsf.busobject.BusObjectConfig;
import com.eibus.xml.nom.Document;
import com.eibus.xml.nom.Node;
import com.eibus.xml.nom.XMLException;
import com.eibus.xml.xpath.XPath;
import com.eibus.xml.xpath.XPathResult;
import com.novell.ldap.LDAPAttribute;
import com.novell.ldap.LDAPAttributeSet;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
public class employee extends employeeBase
{
public employee()
{
this((BusObjectConfig)null);
}
public employee(BusObjectConfig config)
{
super(config);
}
public static void CallLDAPTest()
{
//Using outside method
try
{
//LDAPConnection connection=CordysConfig.getToLDAPConnection();
LDAPConnection connection=BSF.getLDAPDirectory().getConnection();
LDAPAttributeSet authUsersAttributeSetUser = new LDAPAttributeSet();
authUsersAttributeSetUser.add( new LDAPAttribute("objectclass", new String[]{"top","busauthenticationuser"}));
authUsersAttributeSetUser.add( new LDAPAttribute("cn", "Test001"));
authUsersAttributeSetUser.add( new LDAPAttribute("osidentity", "Test001"));
authUsersAttributeSetUser.add( new LDAPAttribute("description", "It's test"));
authUsersAttributeSetUser.add( new LDAPAttribute("userPassword","Test001"));
String context = CordysConfig.ownerOrgDn;
authUsersAttributeSetUser.add( new LDAPAttribute("defaultcontext", context));
// String userDn = "cn=" + "Test001" + "," + CordysConfig.authenticatedUsersDn;
String userDn = "cn=" + "Test001" + "," + CordysConfig.orgUserDn;
LDAPEntry authUserEntry = new LDAPEntry(userDn, authUsersAttributeSetUser);
connection.add(authUserEntry);
} catch (Exception e) {
e.printStackTrace();
}
// Using cordys wrapped method.
}
public static void CallOutWebServiceTest()
{
// TODO implement body
}
public static void SynEmployee()
{
Document oDocument = new Document();
int iXml;
try {
iXml = oDocument.load("<root><table>text</table><chair>david</chair></root>".getBytes());
XPath oXPath0 = XPath.getXPathInstance("/root/*");
int res[] = oXPath0.selectElementNodes(iXml);
String n1=Node.getName(res[0]);
String va1=Node.getData(res[0]);
String va2=Node.getData(res[1]);
} catch (XMLException e) {
e.printStackTrace();
}
}
public static void Test()
{
// TODO implement body
}
}