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


Java CommunicationException类代码示例

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


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

示例1: testRDNS

import javax.naming.CommunicationException; //导入依赖的package包/类
/**
 * TestCase: get our local address and reverse look it up
 */
@Test
public void testRDNS() throws Exception {
  InetAddress localhost = getLocalIPAddr();
  try {
    String s = DNS.reverseDns(localhost, null);
    LOG.info("Local reverse DNS hostname is " + s);
  } catch (NameNotFoundException | CommunicationException e) {
    if (!localhost.isLinkLocalAddress() || localhost.isLoopbackAddress()) {
      //these addresses probably won't work with rDNS anyway, unless someone
      //has unusual entries in their DNS server mapping 1.0.0.127 to localhost
      LOG.info("Reverse DNS failing as due to incomplete networking", e);
      LOG.info("Address is " + localhost
              + " Loopback=" + localhost.isLoopbackAddress()
              + " Linklocal=" + localhost.isLinkLocalAddress());
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:21,代码来源:TestDNS.java

示例2: loginUser

import javax.naming.CommunicationException; //导入依赖的package包/类
void loginUser(VOUser voUser, String password,
        HttpServletRequest httpRequest, HttpSession session)
        throws LoginException, CommunicationException {
    ServiceAccess serviceAccess = ServiceAccess
            .getServiceAcccessFor(session);
    IdentityService service = getIdService();

    // authenticate the user
    httpRequest.getSession();
    try {
        httpRequest.login(String.valueOf(voUser.getKey()), password);
    } catch (ServletException e) {
        throw new LoginException(e.getMessage());
    }
    serviceAccess.login(voUser, password, httpRequest, getResponse());

    // log info on the successful login
    logger.logInfo(Log4jLogger.ACCESS_LOG,
            LogMessageIdentifier.INFO_USER_LOGIN_SUCCESS,
            voUser.getUserId(), IPResolver.resolveIpAddress(httpRequest),
            voUser.getTenantId());

    // read the user details value object and store it in the session
    session.setAttribute(Constants.SESS_ATTR_USER,
            service.getCurrentUserDetails());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:27,代码来源:ConfirmationBean.java

示例3: getCausedByCommunicationException

import javax.naming.CommunicationException; //导入依赖的package包/类
/**
 * Determines if the caught exception was caused by a communication
 * exception and return it. If so, the LDAP server cannot be reached.
 * 
 * @param caughtException
 *            The exception to check the cause for.
 * @return The first found CommunicationException or null.
 */
private CommunicationException getCausedByCommunicationException(
        Throwable caughtException) {
    Throwable cause = caughtException.getCause();
    while (cause != null) {
        if (cause instanceof CommunicationException) {
            return (CommunicationException) cause;
        }
        if (cause.getMessage()
                .contains("javax.naming.CommunicationException")) {
            return new CommunicationException();
        }
        cause = cause.getCause();
    }
    return null;
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:24,代码来源:EJBServiceAccess.java

示例4: decodeSoa

import javax.naming.CommunicationException; //导入依赖的package包/类
private String decodeSoa(int pos) throws CommunicationException {
    DnsName mname = new DnsName();
    pos = decodeName(pos, mname);
    DnsName rname = new DnsName();
    pos = decodeName(pos, rname);

    long serial = getUInt(pos);
    pos += 4;
    long refresh = getUInt(pos);
    pos += 4;
    long retry = getUInt(pos);
    pos += 4;
    long expire = getUInt(pos);
    pos += 4;
    long minimum = getUInt(pos);    // now used as negative TTL
    pos += 4;

    return (mname + " " + rname + " " + serial + " " +
            refresh + " " + retry + " " + expire + " " + minimum);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ResourceRecord.java

示例5: decodeNaptr

import javax.naming.CommunicationException; //导入依赖的package包/类
private String decodeNaptr(int pos) throws CommunicationException {
    int order = getUShort(pos);
    pos += 2;
    int preference = getUShort(pos);
    pos += 2;
    StringBuffer flags = new StringBuffer();
    pos += decodeCharString(pos, flags);
    StringBuffer services = new StringBuffer();
    pos += decodeCharString(pos, services);
    StringBuffer regexp = new StringBuffer(rdlen);
    pos += decodeCharString(pos, regexp);
    DnsName replacement = decodeName(pos);

    return (order + " " + preference + " " + flags + " " +
            services + " " + regexp + " " + replacement);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:ResourceRecord.java

示例6: toResponse

import javax.naming.CommunicationException; //导入依赖的package包/类
@Override
public Response toResponse(final Throwable exception) {

	/*
	 * Check LDAP communication issue. As this exception is wrapped by a runtime exception brought bySpring-LDAP
	 * (optional dependency), there is no way a create a specific Mapper.
	 */
	if (exception.getCause() instanceof CommunicationException) {
		log.error("LDAP exception", exception);
		return toResponse(Status.SERVICE_UNAVAILABLE, "ldap-down", exception.getCause());
	}

	// Really not managed exception
	log.error("Non managed error", exception);
	
	// Don't expose the associated exception or message since we ignore the content
	return toResponse(Status.INTERNAL_SERVER_ERROR, "internal", null);
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:19,代码来源:FailSafeExceptionMapper.java

示例7: loginUser

import javax.naming.CommunicationException; //导入依赖的package包/类
void loginUser(VOUser voUser, String password, HttpServletRequest httpRequest,
        HttpSession session) throws LoginException, CommunicationException{
    ServiceAccess serviceAccess = ServiceAccess
            .getServiceAcccessFor(session);
    IdentityService service = getIdService();

    // authenticate the user
    serviceAccess.login(voUser, password, httpRequest,
            getResponse());

    // log info on the successful login
    logger.logInfo(Log4jLogger.ACCESS_LOG,
            LogMessageIdentifier.INFO_USER_LOGIN_SUCCESS,
            voUser.getUserId(),
            IPResolver.resolveIpAddress(httpRequest), voUser.getTenantId());

    // read the user details value object and store it in the session
    session.setAttribute(Constants.SESS_ATTR_USER,
            service.getCurrentUserDetails());
}
 
开发者ID:servicecatalog,项目名称:development,代码行数:21,代码来源:ConfirmationBean.java

示例8: getCausedByCommunicationException

import javax.naming.CommunicationException; //导入依赖的package包/类
/**
 * Determines if the caught exception was caused by a communication
 * exception and return it. If so, the LDAP server cannot be reached.
 * 
 * @param caughtException
 *            The exception to check the cause for.
 * @return The first found CommunicationException or null.
 */
private CommunicationException getCausedByCommunicationException(
        Throwable caughtException) {
    Throwable cause = caughtException.getCause();
    while (cause != null) {
        if (cause instanceof CommunicationException) {
            return (CommunicationException) cause;
        }
        if (cause.getMessage().contains(
                "javax.naming.CommunicationException")) {
            return new CommunicationException();
        }
        cause = cause.getCause();
    }
    return null;
}
 
开发者ID:servicecatalog,项目名称:development,代码行数:24,代码来源:EJBServiceAccess.java

示例9: search

import javax.naming.CommunicationException; //导入依赖的package包/类
private NamingEnumeration<SearchResult> search(String name, Attributes matchAttrs) throws NamingException {
    try {
        return searchWithoutRetry(name, matchAttrs);
    } catch (CommunicationException first) {
        // I've seen ldap queries fail occasionally with a CommunicationException "connection closed". So try it twice.
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            // fall-through
        }
        try {
            return searchWithoutRetry(name, matchAttrs);
        } catch (NamingException second) {
            second.addSuppressed(first);
            throw second;
        }
    }
}
 
开发者ID:mlhartme,项目名称:stool,代码行数:19,代码来源:Ldap.java

示例10: testEnsureOnetimeException

import javax.naming.CommunicationException; //导入依赖的package包/类
@Test
public void testEnsureOnetimeException() throws Exception {
  MockLdapContext ldapContext = new MockLdapContext() {
    boolean firstTime = true;
    @Override
    public Attributes getAttributes(String name) throws NamingException {
      if (firstTime) {
        firstTime = false;
        throw new CommunicationException("testing");
      } else {
        return super.getAttributes(name);
      }
    }
  };
  addStandardKeysAndResults(ldapContext);
  AdServer adServer = new AdServer("localhost", "" /*userSearchBaseDN*/,
      "" /*groupSearchBaseDN*/, "" /*userSearchFilter*/,
      "" /*groupSearchFilter*/, ldapContext) {
    @Override
    void recreateLdapContext() {
      // do nothing
    }
  };
  adServer.initialize();
}
 
开发者ID:googlegsa,项目名称:activedirectory,代码行数:26,代码来源:AdServerTest.java

示例11: testEnsureConnectionOnetimeException

import javax.naming.CommunicationException; //导入依赖的package包/类
@Test
public void testEnsureConnectionOnetimeException() throws Exception {
  MockLdapContext ldapContext = new MockLdapContext() {
    boolean firstTime = true;
    @Override
    public Attributes getAttributes(String name) throws NamingException {
      if (firstTime) {
        firstTime = false;
        throw new CommunicationException("testing");
      } else {
        return super.getAttributes(name);
      }
    }
  };
  LdapServer ldapServer = new LdapServer("localhost", "nickname",
      "ou=basedn", "userFilter", "cn,dn" /* attributes */,
      1000 /* traversalRate */, "dn={dn}, cn={cn}", ldapContext) {
    @Override
    void recreateLdapContext() {
      // do nothing
    }
  };
  ldapServer.initialize();
}
 
开发者ID:googlegsa,项目名称:ldap,代码行数:25,代码来源:LdapServerTest.java

示例12: testEnsureConnectionWrapsStartupException

import javax.naming.CommunicationException; //导入依赖的package包/类
@Test
public void testEnsureConnectionWrapsStartupException() throws Exception {
  MockLdapContext ldapContext = new MockLdapContext() {
    @Override
    public Attributes getAttributes(String name) throws NamingException {
      throw new CommunicationException("testing");
    }
  };
  LdapServer ldapServer = new LdapServer("localhost", "nickname",
      "ou=basedn", "userFilter", "cn,dn" /* attributes */,
      1000 /* traversalRate */, "dn={dn}, cn={cn}", ldapContext) {
    @Override
    void recreateLdapContext() {
      throw new StartupException("persistent problem");
    }
  };
  try {
    ldapServer.initialize();
  } catch (RuntimeException re) {
    assertTrue(re.getCause() instanceof NamingException);
    NamingException ne = (NamingException) re.getCause();
    assertTrue(ne.getMessage().contains("recreateLdapContext"));
    assertTrue(ne.getRootCause() instanceof StartupException);
  }
}
 
开发者ID:googlegsa,项目名称:ldap,代码行数:26,代码来源:LdapServerTest.java

示例13: removeNamingListener

import javax.naming.CommunicationException; //导入依赖的package包/类
public void removeNamingListener(NamingListener namingListener)
        throws NamingException {
    if (listeners == null || !listeners.containsKey(namingListener)) {
        return;
    }

    if (namingListener instanceof UnsolicitedNotificationListener) {
        unls.remove(namingListener);
    }

    List<Integer> idList = listeners.remove(namingListener);
    if (idList == null) {
        return;
    }

    try {
        for (Integer id : idList) {
            client.removePersistentSearch(id.intValue(), requestControls);
        }
    } catch (IOException e) {
        CommunicationException ex = new CommunicationException();
        ex.setRootCause(e);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:LdapContextImpl.java

示例14: next

import javax.naming.CommunicationException; //导入依赖的package包/类
/**
 * Retrieves the next element. <code>NoSuchElementException</code> will be
 * thrown, if there is no other elements or <code>close()</code> has been
 * invoked.
 */
public T next() throws NamingException {
    if (values == null || (values.isEmpty() && isFinished)) {
        throw new NoSuchElementException();
    }

    synchronized (values) {
        if (values.isEmpty() && !isFinished) {
            waitMoreElement();
            // wait timeout
            if (values.isEmpty() && !isFinished) {
                if (exception != null) {
                    throw exception;
                }
                // ldap.31=Read LDAP response message time out
                throw new CommunicationException(Messages
                        .getString("ldap.31")); //$NON-NLS-1$
            } else if (values.isEmpty()) {
                throw new NoSuchElementException();
            }
        }
        return values.poll();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:LdapNamingEnumeration.java

示例15: test_getExceptionFromResult

import javax.naming.CommunicationException; //导入依赖的package包/类
public void test_getExceptionFromResult() {
    String message = "error message";
    LdapResult result = getLdapResult(0, message);
    NamingException ex = LdapUtils.getExceptionFromResult(result);
    assertNull(ex);

    // error code map to CommunicationException
    result = getLdapResult(2, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof CommunicationException);
    assertEquals("[LDAP: error code 2 - error message]", ex.getMessage());

    // error code not in map
    result = getLdapResult(100, message);
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof NamingException);
    assertEquals("[LDAP: error code 100 - error message]", ex.getMessage());

    // empty error message
    result = getLdapResult(3, "");
    ex = LdapUtils.getExceptionFromResult(result);
    assertTrue(ex instanceof TimeLimitExceededException);
    assertEquals("[LDAP: error code 3]", ex.getMessage());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:LdapUtilsTest.java


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