@Override public void close() throws IOException { try { context.close(); } catch (NamingException e) { throw new IOException(e); } }
public boolean login(String username, String password) { try { SearchResult ldapUser = lookupUser(username); if (ldapUser != null) { auth(ldapUser.getNameInNamespace(), password).close(); return true; } } catch (NamingException e) { return false; } return false; }
} finally { try { dirContext.close(); } catch (NamingException e) {
} finally { try { dirContext.close(); } catch (NamingException e) {
@Test(groups = "unit") public void should_close_context_when_closed() throws Exception { InitialDirContext mock = mock(InitialDirContext.class); EC2MultiRegionAddressTranslator translator = new EC2MultiRegionAddressTranslator(mock); // ensure close has not been called to this point. verify(mock, times(0)).close(); translator.close(); // ensure close is closed. verify(mock).close(); }
private void closeResources(final InitialDirContext ctx,final NamingEnumeration<SearchResult> resultsEnum,final NamingEnumeration<String> atrEnum) { try { atrEnum.close(); } catch (Exception eom) {} try { resultsEnum.close(); } catch (Exception eom) {} try { ctx.close(); } catch (Exception eom) {} }
public static void closeDirectoryContext(InitialDirContext initialDirContext) { try { initialDirContext.close(); } catch (NamingException e) { LOGGER.warn("Could not close InitialDirContext correctly!", e); } }
@Override public void close() throws IOException { try { context.close(); } catch (NamingException e) { throw new IOException(e); } }
private void closeSafely(InitialDirContext ctx) { try { if (ctx != null) { ctx.close(); ctx = null; } } catch (Exception e) { LOGGER.warn("Exception closing InitialDirContext", e); } }
@Override public void close() throws NamingException { GSSCredential credential = null; try { credential = (GSSCredential) getEnvironment().get(Sasl.CREDENTIALS); } finally { super.close(); } if (credential != null) { try { credential.dispose(); } catch (GSSException e) { // ignore } } }
} finally { try { dirContext.close(); } catch (NamingException e) {
@Test(groups = "unit") public void should_close_context_when_closed() throws Exception { InitialDirContext mock = mock(InitialDirContext.class); EC2MultiRegionAddressTranslator translator = new EC2MultiRegionAddressTranslator(mock); // ensure close has not been called to this point. verify(mock, times(0)).close(); translator.close(); // ensure close is closed. verify(mock).close(); }
} finally { try { dirContext.close(); } catch (NamingException e) {
this.ctx.close();
this.ctx.close();