public static PasswordPolicyResponseControl extractControl(DirContext dirCtx) { LdapContext ctx = (LdapContext) dirCtx; Control[] ctrls = null; try { ctrls = ctx.getResponseControls(); } catch (javax.naming.NamingException e) { logger.error("Failed to obtain response controls", e); } for (int i = 0; ctrls != null && i < ctrls.length; i++) { if (ctrls[i] instanceof PasswordPolicyResponseControl) { return (PasswordPolicyResponseControl) ctrls[i]; } } return null; }
@Override public Control[] getResponseControls() throws NamingException { if ( ! (delegating instanceof LdapContext)) throw Assert.unsupported(); return ((LdapContext) delegating).getResponseControls(); }
@Test(expected = PasswordPolicyException.class) public void lockedPasswordPolicyControlRaisesPasswordPolicyException() throws Exception { when(ctx.getResponseControls()).thenReturn( new Control[] { new PasswordPolicyResponseControl( PasswordPolicyResponseControlTests.OPENLDAP_LOCKED_CTRL) }); doThrow(new NamingException("locked message")).when(ctx).reconnect( any(Control[].class)); ctxSource.getContext("user", "ignored"); } }
Control[] controls = ctx.getResponseControls(); if (controls != null) { for (Control control : controls) { Control[] controls = ctx2.getResponseControls(); if (controls != null) { for (Control control : controls) {
Control[] controls = ctx.getResponseControls(); if (controls != null) { for (Control control : controls) { Control[] controls = ctx2.getResponseControls(); if (controls != null) { for (Control control : controls) {
Control[] contextControls = context.getResponseControls(); if (contextControls != null) { for (Control control : contextControls) {
/** * Gets the response controls. * * @return the response controls, may be null * * @throws NamingException the naming exception */ public Control[] getResponseControls() throws NamingException { return ctx != null ? ctx.getResponseControls() : null; }
@Override public Control[] getResponseControls() throws NamingException { if ( ! (delegating instanceof LdapContext)) throw Assert.unsupported(); return ((LdapContext) delegating).getResponseControls(); }
@Override public Control[] getResponseControls() throws NamingException { if ( ! (delegating instanceof LdapContext)) throw Assert.unsupported(); return ((LdapContext) delegating).getResponseControls(); }
@Override public Object operation() throws NamingException { return ((LdapContext) getDelegate()).getResponseControls(); } }.perform();
@Override public Object operation() throws NamingException { return ((LdapContext) getDelegate()).getResponseControls(); } }.perform();
@Override public Control[] getResponseControls() throws NamingException { if ( ! (delegating instanceof LdapContext)) throw Assert.unsupported(); return ((LdapContext) delegating).getResponseControls(); }
/** * @see LdapContext#getResponseControls() */ public Control[] getResponseControls() throws NamingException { this.assertOpen(); return this.getDelegateLdapContext().getResponseControls(); }
/** * @see javax.naming.ldap.LdapContext#getResponseControls() */ public Control[] getResponseControls() throws NamingException { this.assertOpen(); return this.getDelegateLdapContext().getResponseControls(); }
/** * @see LdapContext#getResponseControls() */ public Control[] getResponseControls() throws NamingException { this.assertOpen(); return this.getDelegateLdapContext().getResponseControls(); }
/** * @see LdapContext#getResponseControls() */ public Control[] getResponseControls() throws NamingException { this.assertOpen(); return this.getDelegateLdapContext().getResponseControls(); }
/** * @see javax.naming.ldap.LdapContext#getResponseControls() */ public Control[] getResponseControls() throws NamingException { this.assertOpen(); return this.getDelegateLdapContext().getResponseControls(); }
@Test public void testPostProcess_NoResponseControls() throws Exception { when(ldapContextMock.getResponseControls()).thenReturn(null); tested.postProcess(ldapContextMock); assertThat(tested.getCookie()).isNull(); assertThat(tested.getPageSize()).isEqualTo(20); assertThat(tested.getResultSize()).isEqualTo(0); }
@Test public void testPostProcess_NonSuccess() throws Exception { byte sortResult = 1; byte[] value = encodeValue(sortResult); SortResponseControl control = new SortResponseControl( "dummy", true, value); when(ldapContextMock.getResponseControls()).thenReturn(new Control[] { control }); tested.postProcess(ldapContextMock); assertThat(tested.isSorted()).isEqualTo(false); assertThat(tested.getResultCode()).isEqualTo(1); }
@Test public void testPostProcess() throws Exception { byte sortResult = 0; // success byte[] value = encodeValue(sortResult); SortResponseControl control = new SortResponseControl( "dummy", true, value); when(ldapContextMock.getResponseControls()).thenReturn( new Control[]{control}); tested.postProcess(ldapContextMock); assertThat(tested.isSorted()).isEqualTo(true); assertThat(tested.getResultCode()).isEqualTo(0); }