当前位置: 首页>>代码示例>>Java>>正文


Java DN.getRDNs方法代码示例

本文整理汇总了Java中com.novell.ldap.util.DN.getRDNs方法的典型用法代码示例。如果您正苦于以下问题:Java DN.getRDNs方法的具体用法?Java DN.getRDNs怎么用?Java DN.getRDNs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.novell.ldap.util.DN的用法示例。


在下文中一共展示了DN.getRDNs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isDescendantOf

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private boolean isDescendantOf(DN parent,DN child) {
	Vector<RDN> parentRDNs = parent.getRDNs();
	Vector<RDN> childRDNs = child.getRDNs();
	
	if (childRDNs.size() < parentRDNs.size()) {
		return false;
	}
	
	int i = childRDNs.size() - 1;
	int l = parentRDNs.size() - 1;
	
	for ( ;l>=0;) {
		if (! parentRDNs.get(l).equals(childRDNs.get(i))) {
			return false;
		}
		i--;
		l--;
	}
	
	return true;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:22,代码来源:AccessMgr.java

示例2: isDescendantOf

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private boolean isDescendantOf(DN parent,DN child) {
	Vector<RDN> parentRDNs = parent.getRDNs();
	Vector<RDN> childRDNs = child.getRDNs();
	
	if (childRDNs.size() <= parentRDNs.size()) {
		return false;
	}
	
	int i = childRDNs.size() - 1;
	int l = parentRDNs.size() - 1;
	
	for ( ;l>=0;) {
		if (! parentRDNs.get(l).equals(childRDNs.get(i))) {
			return false;
		}
		i--;
		l--;
	}
	
	return true;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:22,代码来源:AccessControlItem.java

示例3: add

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
public void add(AddInterceptorChain chain, Entry entry,
		LDAPConstraints constraints) throws LDAPException {
		
		DN dn = new DN(entry.getEntry().getDN());
		Vector<RDN> rdns = dn.getRDNs();
		ListIterator it = rdns.listIterator();
		DN newDN = new DN();
		while (it.hasNext()) {
			RDN rdn = (RDN) it.next();
			if (! this.attribsToRemove.contains(rdn.getType().toLowerCase())) {
				newDN.addRDNToBack(rdn);
			}
			
			if (this.attribsToStore.contains(rdn.getType().toLowerCase())) {
				entry.getEntry().getAttributeSet().add(new LDAPAttribute(rdn.getType(),rdn.getValue()));
			}
		}
		
		entry.setDN(newDN);
		
		chain.nextAdd(entry,constraints);

}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:24,代码来源:FlattenNamespace.java

示例4: setExternalDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private void setExternalDN(Entry entry) {
	DN dn = new DN(entry.getEntry().getDN());
	Vector<RDN> rdns = dn.getRDNs();
	if (rdns.size() == 0 || ! rdns.get(0).getType().equalsIgnoreCase(this.internalRDN)) {
		return;
	}
	
	String dnlower = entry.getEntry().getDN().toLowerCase();
	String strdn = this.in2out.get(dnlower);
	
	if (strdn != null) {
		entry.setEntry(new LDAPEntry(strdn,entry.getEntry().getAttributeSet()));
		return;
	}
	
	String val = entry.getEntry().getAttributeSet().getAttribute(this.externalRDN).getStringValue();
	DN newdn = new DN();
	RDN rdn = new RDN();
	rdn.add(this.externalRDN, val, val);
	newdn.addRDN(rdn);
	
	for (int i=1,m=rdns.size();i<m;i++) {
		newdn.addRDNToBack(rdns.elementAt(i));
	}
	
	this.in2out.put(dnlower, newdn.toString());
	
	entry.setEntry(new LDAPEntry(newdn.toString(),entry.getEntry().getAttributeSet()));
	
	
	
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:34,代码来源:SetRDN.java

示例5: getInternalDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private DN getInternalDN(DN externalDN,InterceptorChain chain,LDAPEntry toadd) throws LDAPException {
	Vector<RDN> externalRDNs =  externalDN.getRDNs();
	
	//check to make sure we need to do the mapping
	if (externalRDNs.size() == 0 || ! externalRDNs.get(0).getType().equalsIgnoreCase(this.externalRDN)) {
		return externalDN;
	}
	
	
	//check to see if we have it cached
	String dnstr = this.out2in.get(externalDN.toString().toLowerCase());
	
	if (dnstr != null) {
		return new DN(dnstr);
	}
	
	//we need to retrieve the attribute via a search
	Results results = new Results(null,chain.getPositionInChain(this));
	SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this));
	DN base = new DN();
	for (int i=1,m=externalRDNs.size();i<m;i++) {
		base.addRDNToBack(externalRDNs.get(i));
	}
	
	String val = "";
	
	if (toadd == null) {
		ArrayList<Attribute> attributes = new ArrayList<Attribute>();
		attributes.add(new Attribute(this.internalRDN));
		
		Filter filter = new Filter("(" + this.externalRDN + "=" + externalRDNs.get(0).getValue() +")");
		
		schain.nextSearch(new DistinguishedName(base), new Int(1), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
		
		results.start();
		
		
		Entry entry = null;
		
		if (results.hasMore()) {
			entry = results.next();
		} else {
			results.finish();
			throw new LDAPException("No Such Object",LDAPException.NO_SUCH_OBJECT,"No Such Object");
		}
		
		val = entry.getEntry().getAttribute(this.internalRDN).getStringValue();
	} else {
		val = toadd.getAttribute(this.internalRDN).getStringValue();
	}
	
	DN internalDN = new DN();
	RDN rdn = new RDN();
	rdn.add(this.internalRDN, val, val);
	internalDN.addRDN(rdn);
	for (int i=1,m=externalRDNs.size();i<m;i++) {
		internalDN.addRDNToBack(externalRDNs.get(i));
	}
	
	this.out2in.put(externalDN.toString().toLowerCase(), internalDN.toString());
	return internalDN;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:63,代码来源:SetRDN.java

示例6: add

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private void add(AccessControlItem aci) {
	DN dn = aci.getDn();
	if (aci.getNum() == 3) {
		////System.out.println();
	}
	//work in reverse from the end of the dn to the front
	Vector<RDN> rdns = dn.getRDNs();
	
	for (int i=rdns.size() - 1;i>=0;i--) {
		DN levelDN = new DN();
		for (int l=rdns.size() - 1;l>=i;l--) {
			
			levelDN.addRDNToFront(rdns.get(l));
			AciLevel level = this.acl.get(levelDN);
			if (level == null) {
				level = new AciLevel();
				level.acis = new ArrayList<AccessControlItem>();
				//we need to add all parents
				
				for (int m=1;m<levelDN.countRDNs();m++) {
					DN parentDNs = new DN();
					Vector<RDN> parentRDNs = levelDN.getRDNs();
					for (int k=m;k<levelDN.countRDNs();k++) {
						parentDNs.addRDNToBack(parentRDNs.get(k));
					}
					
					AciLevel parentLevel = this.acl.get(parentDNs);
					if (parentLevel != null) {
						Iterator<AccessControlItem> aciIt = parentLevel.acis.iterator();
						while (aciIt.hasNext()) {
							AccessControlItem aciItem = aciIt.next();
							if (! level.acis.contains(aciItem)) {
								level.acis.add(aciItem);
							}
						}
					}
				}
				
				this.acl.put(levelDN,level);
			}
			
			if (! level.acis.contains(aci)) {
				level.acis.add(aci);
			}
		}
	}
	
	//now make sure we get all children too
	Iterator<DN> it = this.acl.keySet().iterator();
	while (it.hasNext()) {
		dn = it.next();
		if (this.isDescendantOf(aci.getDn(),dn) && ! acl.get(dn).acis.contains(aci)) {
			acl.get(dn).acis.add(aci);
		}
	}
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:57,代码来源:AccessMgr.java

示例7: setExternalDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private void setExternalDN(Entry entry) {
	
	/*if (this.toIgnore.contains(entry.getEntry().getDN())) {
		//we know to ignore
		return;
	}*/
	
	boolean ocFound = false;
	if (entry.getEntry().getAttribute("OBJECTCLASS") != null) {
		for (String oc : entry.getEntry().getAttribute("OBJECTCLASS").getStringValueArray()) {
			if (oc.equalsIgnoreCase(this.objectClass)) {
				ocFound = true;
				break;
			}
		}
	}
	
	if (! ocFound) {
		this.toIgnore.add(entry.getEntry().getDN());
		return;
	}
	
	
	DN dn = new DN(entry.getEntry().getDN());
	Vector<RDN> rdns = dn.getRDNs();
	if (rdns.size() == 0 || ! rdns.get(0).getType().equalsIgnoreCase(this.internalRDN)) {
		return;
	}
	
	String dnlower = entry.getEntry().getDN().toLowerCase();
	String strdn = null;//this.in2out.get(dnlower);
	
	if (strdn != null) {
		entry.setEntry(new LDAPEntry(strdn,entry.getEntry().getAttributeSet()));
		return;
	}
	
	if ( entry.getEntry().getAttributeSet().getAttribute(this.externalRDN) == null) {
		return;
	}
	
	String val = entry.getEntry().getAttributeSet().getAttribute(this.externalRDN).getStringValue();
	DN newdn = new DN();
	RDN rdn = new RDN();
	rdn.add(this.externalRDN, val, val);
	newdn.addRDN(rdn);
	
	for (int i=1,m=rdns.size();i<m;i++) {
		newdn.addRDNToBack(rdns.elementAt(i));
	}
	
	this.in2out.put(dnlower, newdn.toString());
	
	entry.setEntry(new LDAPEntry(newdn.toString(),entry.getEntry().getAttributeSet()));
	
	
	
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:60,代码来源:SetRDN.java

示例8: getExternalAttrDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private String getExternalAttrDN(String internalDN,InterceptorChain chain) throws LDAPException {
	/*if (this.toIgnore.contains(internalDN)) {
		return internalDN;
	}*/
	
	String externalDN = null;//this.in2out.get(internalDN.toLowerCase());
	if (externalDN != null) {
		return externalDN;
	}
	
	
	DN internalDNdn = new DN(internalDN);
	Vector rdns = internalDNdn.getRDNs();
	DN base = new DN();
	for (int i=1;i<rdns.size();i++) {
		base.addRDNToBack((RDN) rdns.get(i));
	}
	
	String internalRDNVal = ((RDN) rdns.get(0)).getValue();
	String internalRDNName = ((RDN) rdns.get(0)).getType();
	
	ArrayList<Attribute> attributes = new ArrayList<Attribute>();
	attributes.add(new Attribute(this.externalRDN));
	attributes.add(new Attribute(this.objectClass));
	
	StringBuffer b = new StringBuffer();
	b.append("(&(objectClass=").append(this.objectClass).append(")(").append(internalRDNName).append('=').append(internalRDNVal).append("))");
	//b.append('(').append(this.externalRDN).append('=').append(externalRDNs.get(0).getValue()).append(')');
	Filter filter = new Filter(b.toString());
	
	
	Results results = new Results(null,chain.getPositionInChain(this) + 1);
	SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this) + 1);
	
	
	logger.info("Base : '" + base + "'" );
	
	schain.nextSearch(new DistinguishedName(base), new Int(1), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
	
	results.start();
	
	
	Entry entry = null;
	
	if (results.hasMore()) {
		entry = results.next();
	} else {
		results.finish();
		//Assume this isn't the correct obectClass
		this.toIgnore.add(internalDN.toString());
		return internalDN;
	}
	
	String val = entry.getEntry().getAttribute(this.externalRDN).getStringValue();
	
	DN newExternal = new DN();
	b.setLength(0);
	b.append(this.externalRDN).append('=').append(val);
	RDN rdn = new RDN(b.toString());
	
	newExternal.addRDN(rdn);
	
	for (int i=1;i<rdns.size();i++) {
		newExternal.addRDNToBack((RDN) rdns.get(i));
	}
	
	this.in2out.put(internalDN.toLowerCase() , newExternal.toString().toLowerCase());
	return newExternal.toString();
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:71,代码来源:SetRDN.java

示例9: getInternalAttrDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private String getInternalAttrDN(String externalDN,InterceptorChain chain) throws LDAPException {
	/*if (this.toIgnore.contains(externalDN)) {
		return externalDN;
	}*/
	
	String internalDN = null;//this.out2in.get(externalDN.toLowerCase());
	if (internalDN != null) {
		return internalDN;
	}
	
	
	DN externalDNdn = new DN(externalDN);
	Vector rdns = externalDNdn.getRDNs();
	DN base = new DN();
	for (int i=1;i<rdns.size();i++) {
		base.addRDNToBack((RDN) rdns.get(i));
	}
	
	String externalRDNVal = ((RDN) rdns.get(0)).getValue();
	String externalRDNName = ((RDN) rdns.get(0)).getType();
	
	ArrayList<Attribute> attributes = new ArrayList<Attribute>();
	attributes.add(new Attribute(this.internalRDN));
	attributes.add(new Attribute(this.objectClass));
	
	StringBuffer b = new StringBuffer();
	b.append("(&(objectClass=").append(this.objectClass).append(")(").append(externalRDNName).append('=').append(externalRDNVal).append("))");
	//b.append('(').append(this.externalRDN).append('=').append(externalRDNs.get(0).getValue()).append(')');
	Filter filter = new Filter(b.toString());
	
	
	Results results = new Results(null,chain.getPositionInChain(this) + 1);
	SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this) + 1);
	
	schain.nextSearch(new DistinguishedName(base), new Int(1), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
	
	results.start();
	
	
	Entry entry = null;
	
	if (results.hasMore()) {
		entry = results.next();
	} else {
		results.finish();
		//Assume this isn't the correct obectClass
		this.toIgnore.add(externalDN.toString());
		return externalDN;
	}
	
	String val = entry.getEntry().getAttribute(this.internalRDN).getStringValue();
	
	DN newInternal = new DN();
	b.setLength(0);
	b.append(this.internalRDN).append('=').append(val);
	RDN rdn = new RDN(b.toString());
	
	newInternal.addRDN(rdn);
	
	for (int i=1;i<rdns.size();i++) {
		newInternal.addRDNToBack((RDN) rdns.get(i));
	}
	
	this.out2in.put(externalDN.toLowerCase() , newInternal.toString().toLowerCase());
	return newInternal.toString();
	
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:68,代码来源:SetRDN.java

示例10: getInternalDN

import com.novell.ldap.util.DN; //导入方法依赖的package包/类
private DN getInternalDN(DN externalDN,InterceptorChain chain,LDAPEntry toadd) throws LDAPException {
	Vector<RDN> externalRDNs =  externalDN.getRDNs();
	
	//first see if we can ignore
	/*if (this.toIgnore.contains(externalDN.toString())) {
		return externalDN;
	}*/
	
	//check to make sure we need to do the mapping
	if (externalRDNs.size() == 0 || ! externalRDNs.get(0).getType().equalsIgnoreCase(this.externalRDN)) {
		return externalDN;
	}
	
	
	//check to see if we have it cached
	String dnstr = null;//this.out2in.get(externalDN.toString().toLowerCase());
	
	if (dnstr != null) {
		return new DN(dnstr);
	}
	
	//we need to retrieve the attribute via a search
	Results results = new Results(null,chain.getPositionInChain(this) + 1);
	SearchInterceptorChain schain = chain.createSearchChain(chain.getPositionInChain(this) + 1);
	DN base = new DN();
	for (int i=1,m=externalRDNs.size();i<m;i++) {
		base.addRDNToBack(externalRDNs.get(i));
	}
	
	String val = "";
	
	if (toadd == null) {
		ArrayList<Attribute> attributes = new ArrayList<Attribute>();
		attributes.add(new Attribute(this.internalRDN));
		attributes.add(new Attribute(this.objectClass));
		
		StringBuffer b = new StringBuffer();
		b.append("(&(objectClass=").append(this.objectClass).append(")(").append(this.externalRDN).append('=').append(externalRDNs.get(0).getValue()).append("))");
		//b.append('(').append(this.externalRDN).append('=').append(externalRDNs.get(0).getValue()).append(')');
		Filter filter = new Filter(b.toString());
		
		schain.nextSearch(new DistinguishedName(base), new Int(1), filter, attributes, new Bool(false), results, new LDAPSearchConstraints());
		
		results.start();
		
		
		Entry entry = null;
		
		if (results.hasMore()) {
			entry = results.next();
		} else {
			results.finish();
			//Assume this isn't the correct obectClass
			this.toIgnore.add(externalDN.toString());
			return externalDN;
		}
		
		val = entry.getEntry().getAttribute(this.internalRDN).getStringValue();

	} else {
		val = toadd.getAttribute(this.internalRDN).getStringValue();
	}
	
	DN internalDN = new DN();
	RDN rdn = new RDN();
	rdn.add(this.internalRDN, val, val);
	internalDN.addRDN(rdn);
	for (int i=1,m=externalRDNs.size();i<m;i++) {
		internalDN.addRDNToBack(externalRDNs.get(i));
	}
	
	this.out2in.put(externalDN.toString().toLowerCase(), internalDN.toString());
	return internalDN;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:75,代码来源:SetRDN.java


注:本文中的com.novell.ldap.util.DN.getRDNs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。