package com.ca.jndiproviders.dsml;
import com.ca.commons.naming.DXNamingEnumeration;
import com.ca.commons.naming.DN;
import com.ca.commons.cbutil.CBBase64;
import com.ca.commons.cbutil.CBBase64EncodingException;
import javax.naming.directory.*;
import javax.naming.*;
import javax.naming.ldap.Control;
import javax.naming.ldap.ExtendedRequest;
import javax.naming.ldap.ExtendedResponse;
import javax.naming.ldap.LdapContext;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
/**
* <p>This is a DSML jndiproviders context, that provides support for all the basic DSML operations.</p>
* <p/>
* <p>However, it deliberately does *not* support:</p>
* <ul>
* <li>binding java objects - the bind methods are not implemented. Users will need to do their
* own serialisation if they want this functionality.
* <li> referrals aren't implemented yet.
* <li> ldap v3 extensions.
* <li> composite names spanning multiple namespaces - all names are DSML names only. (Composite
* names are a bloody stupid idea that come close to making jndiproviders unusable, IMNSHO - CB)
* </ul>
* <p/>
* <p>If you need the above features, you may be better off using the Sun DSML provider which is
* far more ambitious in scope (but which has some licencing problems, and is a bit rocky in parts).</p>
*/
/*
* DSML SERVER ERROR NOTES
*
* Server is incorrectly parsing escaped dns - e.g. dn="cn=Vivienne \"LEVER\", ... ".
* Server is returning HTTP 500, which prevents parsing of returned soap error
*
*/
//TODO: schema support??
//TODO: we ended up using strings rather than names, so adjust all methods to chain to the string methods instead of the name methods.
//TODO: makes heavy use of static stuff - may not be thread safe.
public class DsmlContext implements LdapContext
{
// Formatting
private static int TABLEN = 4;
private static String TAB = " ";
private static String TAB2 = TAB + TAB;
private static String TAB3 = TAB2 + TAB;
private static String TAB4 = TAB3 + TAB;
private static String TAB5 = TAB4 + TAB;
private static String TAB6 = TAB5 + TAB;
private static String SOAPHEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
TAB + "<soap-env:Envelope xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
TAB2 + "<soap-env:Body>\n";
private static String SOAPFOOTER = TAB2 + "</soap-env:Body>\n" +
TAB + "</soap-env:Envelope>";
private static String DSMLHEADER = TAB3 + "<dsml:batchRequest xmlns:dsml=\"urn:oasis:names:tc:DSML:2:0:core\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n";
private static String DSMLFOOTER = TAB3 + "</dsml:batchRequest>\n";
private static String SEARCHFOOTER = TAB3 + "</dsml:searchRequest>\n";
private static String STANDARDHEADER = SOAPHEADER + DSMLHEADER;
private static String STANDARDFOOTER = DSMLFOOTER + SOAPFOOTER;
// SEARCH SCOPE CONSTANTS
private static String BASEOBJECT = "baseObject";
private static String SINGLELEVEL = "singleLevel";
private static String WHOLESUBTREE = "wholeSubtree";
private static String[] SCOPEOPTIONS = new String[]{BASEOBJECT, SINGLELEVEL, WHOLESUBTREE};
// SEARCH ALIAS DEREF OPTIONS
private static String NEVER = "neverDerefAliases";
private static String SEARCHING = "derefInSearching";
private static String FINDING = "derefFindingBaseObj";
private static String ALWAYS = "derefAlways";
private static String[] ALIASOPTIONS = new String[]{NEVER, SEARCHING, FINDING, ALWAYS};
// Default Search Controls
private static SearchControls DEFAULT_SEARCH_CONTROLS = new SearchControls();
protected Hashtable environment;
// the name of the context (as set by 'createSubcontext' methods
private String contextName = "";
private static Logger log = Logger.getLogger(DsmlContext.class.getName());
// Debug
{
log.setLevel(Level.FINEST);
}
/**
* <p>This constructs the XML tag and tag attributes for a DSML search operation start tag. (filter and attributes elements
* must be added separately, the end tag is a defined constant.)
* <p/>
* <p>e.g.
* <pre>
* <dsml:searchRequest requestID="1" dn="cn=schema" scope="baseObject" derefAliases="derefInSearching">
* </pre>
* <p/>
* something like
*
* @param searchHeader an existing string buffer to append the search header information in.
* @param dn the dn to search from
* @param scope the search scope, must be one of 'baseLevel', 'singleLevel' or 'wholeSubtree' (see constants)
* @param derefAliases how to handle aliases. must be on of 'neverDerefAliases', 'derefInSearching', 'derefFindingBaseObj', 'derefAlways' (see constants)
* @param sizeLimit the LDAP search size limit - default is 0 (unlimited by client)
* @param timeLimit the LDAP search time limit - default is 0 (unlimited by client)
* @param typesOnly - no idea, but it's in the spec.
* @return a string buffer containing the raw xml for a search operation.
* @throws NamingException
*/
private static StringBuffer getSearchRequestHeader(StringBuffer searchHeader, String dn, String scope, String derefAliases, long sizeLimit, int timeLimit, boolean typesOnly)
throws NamingException
{
// sanity check arguments
if (!checkValidity(SCOPEOPTIONS, scope))
throw new NamingException("search scope argument '" + scope + "' is invalid");
if (!checkValidity(ALIASOPTIONS, derefAliases))
{
if (derefAliases != null) log.info("bad alias option passed '" + derefAliases + "'");
derefAliases = SEARCHING;
}
if (searchHeader == null)
searchHeader = new StringBuffer();
searchHeader.append(TAB4 + "<dsml:searchRequest dn=\""); // TODO: requestID is optional - let's drop it in the final version - CB
searchHeader.append(escapeName(dn));
searchHeader.append("\" scope=\"").append(scope);
searchHeader.append("\" derefAliases=\"").append(derefAliases);
if (sizeLimit > 0)
searchHeader.append("\" sizeLimit=\"").append(sizeLimit);
if (timeLimit > 0)
searchHeader.append("\" timeLimit=\"").append(timeLimit);
// never used?
if (typesOnly == true)
searchHeader.append("\" typesOnly=\"").append(typesOnly);
searchHeader.append("\">\n");
log.finest("created search header: " + searchHeader);
return searchHeader;
}
/**
* <p>This constructs the XML tag and elements for a DSML search attribute list
* <p/>
* e.g.
* <pre>
* >dsml:attributes<
* >dsml:attribute name="attributeTypes"/<
* >dsml:attribute name="objectClasses"/<
* >dsml:attribute name="matchingRules"/<
* >dsml:attribute name="ldapSyntaxes"/<
* >dsml:attribute name="*"/<
* >/dsml:attributes<
* </pre>
*
* @param searchAttributes an existing string buffer to append the search attribute list information to
* @param attributes a string array of attribute names
*
* @return the search request attributes
*/
private static StringBuffer getSearchRequestAttributes(StringBuffer searchAttributes, String[] attributes)
{
if (attributes == null || attributes.length == 0)
{
return searchAttributes; // do nothing if there are no specific attributes (means return all)
}
if (searchAttributes == null)
searchAttributes = new StringBuffer(40 + 80 * attributes.length);
searchAttributes.append(TAB5 +
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java的开源LDAP浏览器 JXplorer.zip
共225个文件
java:220个
properties:2个
html:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 119 浏览量
2023-06-17
00:44:03
上传
评论
收藏 789KB ZIP 举报
温馨提示
基于Java的开源LDAP浏览器 JXplorer.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于Java的开源LDAP浏览器 JXplorer.zip (225个子文件)
concurrency.diff 3KB
package.html 1KB
DsmlContext.java 121KB
HTMLTemplateDisplay.java 108KB
TestProviderContext.java 95KB
SmartTree.java 81KB
TCPInterceptor.java 65KB
JNDIOps.java 65KB
SchemaOps.java 56KB
MainMenu.java 53KB
TestJNDIOps.java 52KB
DsmlContextTest.java 51KB
CBUtility.java 48KB
DXAttributes.java 48KB
KeystoreGUI.java 47KB
SearchGUI.java 44KB
JNDIDataBroker.java 41KB
JXplorerBrowser.java 37KB
AttributeDisplay.java 37KB
AdvancedOptions.java 34KB
DERCoder.java 32KB
DXAttribute.java 31KB
TableAttributeEditor.java 31KB
LdifUtility.java 30KB
generalizedtimeeditor.java 30KB
CBAutoGUI.java 29KB
NewEntryWin.java 26KB
jcrypt.java 26KB
BuildFilterPanel.java 26KB
SmartPopupTool.java 26KB
JXConfig.java 24KB
DataBroker.java 24KB
RDN.java 24KB
AttributeTableModel.java 24KB
SmartNode.java 23KB
SearchModel.java 23KB
ReturnAttributesDisplay.java 23KB
DataQuery.java 23KB
JXplorer.java 23KB
AttributeValueCellEditor.java 22KB
DN.java 22KB
ReturnAttributesDialog.java 21KB
Base64.java 21KB
JXSSLSocketFactory.java 21KB
userpasswordeditor.java 21KB
CBSaveLoadTemplate.java 21KB
CBBase64.java 21KB
CBOpenConWin.java 21KB
JndiSocketFactory.java 21KB
CBCache.java 21KB
BasicOps.java 20KB
TestProviderContextTest.java 20KB
DXOps.java 20KB
SchemaOpsTest.java 19KB
OfflineDataBroker.java 19KB
CertViewer.java 19KB
ASN1Object.java 19KB
SchemaDataBroker.java 18KB
BookMarks.java 18KB
LdifImport.java 18KB
ConnectionData.java 17KB
StopMonitor.java 17KB
TestJNDIBulkOps.java 17KB
CertDetailsViewPanel.java 16KB
basicbinaryeditor.java 16KB
ChangeObjectClassWin.java 16KB
JXOpenConWin.java 16KB
LdifUtilityTest.java 16KB
CBLocalization.java 16KB
CBParse.java 16KB
LdifExport.java 16KB
Name.java 15KB
AdvancedOps.java 15KB
ASN1OID.java 14KB
CBResourceBundle.java 13KB
NameUtility.java 13KB
CBSecurity.java 13KB
SmartTreeCellEditor.java 13KB
MyHTMLEditorKit.java 12KB
CBJarResource.java 12KB
SmartModel.java 11KB
AttributeValue.java 11KB
CBTableSorter.java 11KB
DNTest.java 11KB
CBXMLFormatter.java 11KB
JoinFilterPanel.java 11KB
Special.java 10KB
jpegphotoeditor.java 10KB
GeneralName.java 10KB
CBErrorWin.java 9KB
CBHelpSystem.java 9KB
CBIntText.java 9KB
JXTrustManager.java 9KB
defaultbinaryeditor.java 9KB
audioeditor.java 9KB
DXAttributesTest.java 8KB
SmartPopupTableTool.java 8KB
CBSystemProperties.java 8KB
ButtonRegister.java 8KB
ButtonBar.java 8KB
共 225 条
- 1
- 2
- 3
资源评论
快乐无限出发
- 粉丝: 1126
- 资源: 7260
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功