• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReferralException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.naming.ReferralException的典型用法代码示例。如果您正苦于以下问题:Java ReferralException类的具体用法?Java ReferralException怎么用?Java ReferralException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: extendedOperation

import javax.naming.ReferralException; //导入依赖的package包/类
public ExtendedResponse extendedOperation(ExtendedRequest request)
        throws NamingException {
    ExtendedOp op = new ExtendedOp(request);
    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            LdapContext referralContext = (LdapContext) getReferralContext(e);
            return referralContext.extendedOperation(request);
        }
        throw e;
    }
    ExtendedResponse response = op.getExtendedResponse();
    // set existing underlying socket to startTls extended response
    if (response instanceof StartTlsResponseImpl) {
        ((StartTlsResponseImpl) response).setSocket(client.getSocket());
    }
    return response;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:LdapContextImpl.java


示例2: isFollowReferral

import javax.naming.ReferralException; //导入依赖的package包/类
private boolean isFollowReferral(ReferralException e)
        throws ReferralException, PartialResultException {
    // ignore referral
    String action = (String) env.get(Context.REFERRAL);
    if (action == null) {
        action = "ignore";
    }

    if ("follow".equals(action)) {
        return true;
    } else if ("throw".equals(action)) {
        return false;

    } else if ("ignore".equals(action)) {
        // ldap.1A=[LDAP: error code 10 - Referral]
        throw new PartialResultException(Messages.getString("ldap.1A"));

    } else {
        throw new IllegalArgumentException(Messages.getString(
                "ldap.30", new Object[] { //$NON-NLS-1$
                env.get(Context.REFERRAL), Context.REFERRAL }));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:LdapContextImpl.java


示例3: createSubcontext

import javax.naming.ReferralException; //导入依赖的package包/类
@Override
public DirContext createSubcontext(Name name, Attributes attributes)
        throws NamingException {
    int size = name.size();
    Hashtable<String, Object> subSchemaTree = doLookup(name
            .getPrefix(size - 1), size - 1);

    if (null == attributes || attributes.size() == 0) {
        // jndi.8D=Must supply attributes describing schema
        throw new SchemaViolationException(Messages.getString("jndi.8D")); //$NON-NLS-1$
    }

    if (level - size == 2) {
        // jndi.8E=Cannot create new entry under schema root
        throw new SchemaViolationException(Messages.getString("jndi.8E")); //$NON-NLS-1$
    }

    String subSchemaType = name.getSuffix(size - 1).toString();

    if (subSchemaTree.get(subSchemaType.toLowerCase()) != null) {
        throw new NameAlreadyBoundException(subSchemaType);
    }

    String schemaLine = SchemaParser.format(attributes);

    ModifyOp op = new ModifyOp(ldapContext.subschemasubentry);
    Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn);
    BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute(
            jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext);
    op.addModification(OperationJndi2Ldap[DirContext.ADD_ATTRIBUTE],
            new LdapAttribute(schemaEntry, ldapContext));
    try {
        doBasicOperation(op);
        subSchemaTree.put(subSchemaType.toLowerCase(), schemaLine);
    } catch (ReferralException e) {
        // TODO
    }

    return (DirContext) lookup(name);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:41,代码来源:LdapSchemaContextImpl.java


示例4: getReferralContext

import javax.naming.ReferralException; //导入依赖的package包/类
private DirContext getReferralContext(ReferralException e)
        throws LimitExceededException, NamingException {
    int limit = 0;
    if (env.get("java.naming.ldap.referral.limit") != null) {
        limit = Integer.valueOf(
                (String) env.get("java.naming.ldap.referral.limit"))
                .intValue();
    }

    if (limit == -1) {
        throw new LimitExceededException(Messages.getString("ldap.25")); //$NON-NLS-1$
    }

    if (limit == 1) {
        limit = -1;
    } else if (limit != 0) {
        limit -= 1;
    }

    Hashtable<Object, Object> newEnv = (Hashtable<Object, Object>) env
            .clone();
    newEnv.put("java.naming.ldap.referral.limit", String.valueOf(limit));
    DirContext referralContext = null;

    while (true) {
        try {
            referralContext = (DirContext) e.getReferralContext(newEnv);
            break;
        } catch (NamingException ex) {
            if (e.skipReferral()) {
                continue;
            }
            throw ex;
        }
    }

    return referralContext;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:LdapContextImpl.java


示例5: processSearchRef

import javax.naming.ReferralException; //导入依赖的package包/类
/**
 * Follow referrals in SearchResultReference. Referrals in
 * SearchResultReference is different with LDAPResult, which may contians
 * filter parts. Filter and dn part of url will overwrite filter and
 * baseObject of last search operation.
 * 
 * @param op
 *            last search operation
 * @param ex
 */
private void processSearchRef(SearchOp op, ReferralException ex) {
    LdapSearchResult result = op.getSearchResult();
    List<String> urls = result.getRefURLs();

    // clean referrals
    result.setRefURLs(null);

    try {
        for (String url : urls) {

            LdapUrlParser urlParser = LdapUtils.parserURL(url, true);
            // if url has dn part overwrite baseObject of last search
            // operation
            if (!urlParser.getBaseObject().equals("")) {
                op.setBaseObject(urlParser.getBaseObject());
            }
            // if url has filter part overwrite filter of last search
            // operation
            if (urlParser.hasFilter()) {
                op.setFilter(urlParser.getFilter());
            }
            LdapContextImpl ctx = (LdapContextImpl) getReferralContext(ex);
            result.setAddress("ldap://" + urlParser.getHost() + ":"
                    + urlParser.getPort() + "/");
            ctx.doSearch(op);
            result.setAddress(null);
        }
    } catch (NamingException e) {
        /*
         * occrus exception, set to search result and return, not continue
         * to follow referral
         * 
         * TODO test the behavior of ri
         * 
         */
        result.setException(e);
        return;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:50,代码来源:LdapContextImpl.java


示例6: rename

import javax.naming.ReferralException; //导入依赖的package包/类
public void rename(Name nOld, Name nNew) throws NamingException {
    checkName(nOld);
    checkName(nNew);

    if (!isInSameNamespace(nOld, nNew)) {
        throw new InvalidNameException(Messages.getString("ldap.2A")); //$NON-NLS-1$
    }

    if (hasMultiNamingSpace(nOld) && hasMultiNamingSpace(nNew)) {
        Context context = findNnsContext(nOld);
        context.rename(nOld.getSuffix(1), nNew.getSuffix(1));
        return;
    }

    // get absolute dn name
    String oldTargetDN = getTargetDN(nOld, contextDn);
    String newTargetDN = getTargetDN(nNew, contextDn);
    LdapName name = new LdapName(newTargetDN);
    Rdn rdn = name.getRdn(name.size() - 1);
    String value = (String) env.get(LDAP_DELETE_RDN);
    // true is default value
    boolean isDeleteRdn = true;
    if (value != null) {
        isDeleteRdn = Boolean.getBoolean(value);
    }

    ModifyDNOp op = new ModifyDNOp(oldTargetDN, rdn.toString(),
            isDeleteRdn, name.getPrefix(name.size() - 1).toString());

    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            DirContext referralContext = getReferralContext(e);
            referralContext.rename(nOld, nNew);
            return;
        }
        throw e;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:41,代码来源:LdapContextImpl.java


示例7: testAllCoveragePurpose

import javax.naming.ReferralException; //导入依赖的package包/类
public void testAllCoveragePurpose() throws NamingException {
	log.setMethod("testAllCoveragePurpose()");
	ReferralException ex = new MockReferralException();
	ex = new MockReferralException("message");

	ex.getReferralContext();
	ex.getReferralContext(null);
	ex.getReferralInfo();
	ex.skipReferral();
	ex.retryReferral();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:ReferralExceptionTest.java


示例8: destroySubcontext

import javax.naming.ReferralException; //导入依赖的package包/类
@Override
public void destroySubcontext(Name name) throws NamingException {
    int size = name.size();
    Hashtable<String, Object> subSchemaTree = doLookup(name
            .getPrefix(size - 1), size - 1);

    String subSchemaType = name.getSuffix(size - 1).toString()
            .toLowerCase();

    Object schema = subSchemaTree.get(jndi2ldap(subSchemaType));
    if (schema == null) {
        // Return silently.
        return;
    }

    if (level - size == 2) {
        // ldap.37=Can't delete schema root
        throw new SchemaViolationException(Messages.getString("ldap.37")); //$NON-NLS-1$
    }

    if (level == size) {
        // Return silently.
        return;
    }

    String schemaLine = schema.toString();
    if (schema instanceof Hashtable) {
        Hashtable<String, Object> table = (Hashtable<String, Object>) schema;
        schemaLine = table.get(SchemaParser.ORIG).toString();
    }

    ModifyOp op = new ModifyOp(ldapContext.subschemasubentry);
    Name modifySchemaName = name.getPrefix(size - 1).addAll(rdn);
    BasicAttribute schemaEntry = new LdapAttribute(new BasicAttribute(
            jndi2ldap(modifySchemaName.toString()), schemaLine), ldapContext);
    op.addModification(OperationJndi2Ldap[DirContext.REMOVE_ATTRIBUTE],
            new LdapAttribute(schemaEntry, ldapContext));
    try {
        doBasicOperation(op);
        subSchemaTree.remove(subSchemaType);
    } catch (ReferralException e) {
        // TODO
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:45,代码来源:LdapSchemaContextImpl.java


示例9: modifyAttributes

import javax.naming.ReferralException; //导入依赖的package包/类
public void modifyAttributes(Name name, ModificationItem[] modificationItems)
        throws NamingException {
    checkName(name);

    if (modificationItems == null) {
        // FIXME: spec say ModificationItem may not be null, but ri
        // silence in this case
        throw new NullPointerException(Messages.getString("ldap.27")); //$NON-NLS-1$
    }

    if (hasMultiNamingSpace(name)) {
        /*
         * multi ns, find next ns context, delegate operation to the next
         * context
         */
        DirContext nns = (DirContext) findNnsContext(name);
        Name remainingName = name.getSuffix(1);
        nns.modifyAttributes(remainingName, modificationItems);
        return;
    }

    if (modificationItems.length == 0) {
        return;
    }

    /*
     * there is only one ldap ns
     */
    // get absolute dn name
    String targetDN = getTargetDN(name, contextDn);
    ModifyOp op = new ModifyOp(targetDN);
    for (ModificationItem item : modificationItems) {
        switch (item.getModificationOp()) {
        case DirContext.ADD_ATTRIBUTE:
            op.addModification(0, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        case DirContext.REMOVE_ATTRIBUTE:
            op.addModification(1, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        case DirContext.REPLACE_ATTRIBUTE:
            op.addModification(2, new LdapAttribute(item.getAttribute(),
                    this));
            break;
        default:
            throw new IllegalArgumentException(Messages.getString(
                    "jndi.14", item.getModificationOp())); //$NON-NLS-1$
        }
    }

    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            DirContext referralContext = getReferralContext(e);
            referralContext.modifyAttributes(name, modificationItems);
            return;
        }
        throw e;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:63,代码来源:LdapContextImpl.java


示例10: createSubcontext

import javax.naming.ReferralException; //导入依赖的package包/类
public DirContext createSubcontext(Name name, Attributes attributes)
        throws NamingException {
    checkName(name);

    if (hasMultiNamingSpace(name)) {
        /*
         * multi ns, find next ns context, delegate operation to the next
         * context
         */
        DirContext nns = (DirContext) findNnsContext(name);
        Name remainingName = name.getSuffix(1);
        return nns.createSubcontext(remainingName, attributes);
    }

    /*
     * there is only one ldap ns
     */

    if (attributes == null) {
        attributes = new BasicAttributes(true);
        Attribute attr = new LdapAttribute("objectClass", this);
        attr.add("top");
        attr.add("javaContainer");
        attributes.put(attr);
    }

    // get absolute dn name
    String targetDN = getTargetDN(name, contextDn);
    // merge attributes from dn and args
    Attributes attrs = mergeAttributes(attributes,
            getAttributesFromDN(name));

    // convert to LdapAttribute
    List<LdapAttribute> la = new ArrayList<LdapAttribute>(attrs.size());
    NamingEnumeration<? extends Attribute> enu = attrs.getAll();
    while (enu.hasMore()) {
        Attribute att = enu.next();
        if (att.size() > 0) {
            la.add(new LdapAttribute(att, this));
        }
    }

    // do add operation
    AddOp op = new AddOp(targetDN, la);
    try {
        doBasicOperation(op);
    } catch (ReferralException e) {
        if (isFollowReferral(e)) {
            DirContext referralContext = getReferralContext(e);
            return referralContext.createSubcontext(name, attributes);
        }
        throw e;
    }

    LdapResult result = op.getResult();
    return new LdapContextImpl(this, env, result.getMachedDN());
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:58,代码来源:LdapContextImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EmptyArrays类代码示例发布时间:2022-05-21
下一篇:
Java BukkitObjectInputStream类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap