if (value.length() <= i + 1) { throw new BadLdapGrammarException( "Unexpected end of value " + "unterminated '\\'"); throw new BadLdapGrammarException("Unexpected end of value " + "expected special or hex, found '" + nextChar + "'");
@Test public void contextEnvironmentPropertiesUsed() throws Exception { Hashtable<String, Object> env = new Hashtable<>(); env.put("java.naming.ldap.factory.socket", "unknown.package.NonExistingSocketFactory"); provider.setContextEnvironmentProperties(env); try { provider.authenticate(joe); fail("CommunicationException was expected with a root cause of ClassNotFoundException"); } catch (org.springframework.ldap.CommunicationException expected) { assertThat(expected.getRootCause()).isInstanceOf(ClassNotFoundException.class); } }
@Test public void authenticateWithNamingException() { UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken( "ben", "benspassword"); LdapAuthenticator mockAuthenticator = mock(LdapAuthenticator.class); CommunicationException expectedCause = new CommunicationException( new javax.naming.CommunicationException()); when(mockAuthenticator.authenticate(authRequest)).thenThrow(expectedCause); LdapAuthenticationProvider ldapProvider = new LdapAuthenticationProvider( mockAuthenticator); try { ldapProvider.authenticate(authRequest); fail("Expected Exception"); } catch (InternalAuthenticationServiceException success) { assertThat(success.getCause()).isSameAs(expectedCause); } }
public List search(Name base, String filter, SearchControls controls, ContextMapper mapper, DirContextProcessor processor) { assureReturnObjFlagSet(controls); ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler( mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
@Override protected DirContextOperations doAuthentication( UsernamePasswordAuthenticationToken authentication) { try { return getAuthenticator().authenticate(authentication); } catch (PasswordPolicyException ppe) { // The only reason a ppolicy exception can occur during a bind is that the // account is locked. throw new LockedException(this.messages.getMessage( ppe.getStatus().getErrorCode(), ppe.getStatus().getDefaultMessage())); } catch (UsernameNotFoundException notFound) { if (this.hideUserNotFoundExceptions) { throw new BadCredentialsException(this.messages.getMessage( "LdapAuthenticationProvider.badCredentials", "Bad credentials")); } else { throw notFound; } } catch (NamingException ldapAccessFailure) { throw new InternalAuthenticationServiceException( ldapAccessFailure.getMessage(), ldapAccessFailure); } }
public List listBindings(Name base, NameClassPairMapper mapper) { CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler( mapper); listBindings(base, handler); return handler.getList(); }
public List list(String base, NameClassPairMapper mapper) { CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler( mapper); list(base, handler); return handler.getList(); }
public List search(String base, String filter, SearchControls controls, AttributesMapper mapper, DirContextProcessor processor) { AttributesMapperCallbackHandler handler = new AttributesMapperCallbackHandler( mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
public List search(Name base, String filter, SearchControls controls, AttributesMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); }
public List listBindings(String base, ContextMapper mapper) { ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler( mapper); listBindings(base, handler); return handler.getList(); }
private Object executeWithContext(ContextExecutor ce, DirContext ctx) { try { return ce.executeWithContext(ctx); } catch (NamingException e) { throw getExceptionTranslator().translate(e); } finally { closeContext(ctx); } }
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) { try { return mapper.mapFromNameClassPair(nameClassPair); } catch (NamingException e) { throw getExceptionTranslator().translate(e); } } }
public Object executeReadOnly(ContextExecutor ce) { DirContext ctx = contextSource.getReadOnlyContext(); return executeWithContext(ce, ctx); }
return handleUnprocessableEntity(model, response, "error_message", x.getMessage(), "invitations/accept_invite"); } catch (Exception x) { logger.error("Unable to authenticate against LDAP", x);
if (value.length() <= i + 1) { throw new BadLdapGrammarException( "Unexpected end of value " + "unterminated '\\'"); throw new BadLdapGrammarException("Unexpected end of value " + "expected special or hex, found '" + nextChar + "'");
public List search(String base, String filter, SearchControls controls, ContextMapper mapper, DirContextProcessor processor) { assureReturnObjFlagSet(controls); ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler( mapper); search(base, filter, controls, handler, processor); return handler.getList(); }
public List listBindings(String base, NameClassPairMapper mapper) { CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler( mapper); listBindings(base, handler); return handler.getList(); }
public List list(Name base, NameClassPairMapper mapper) { CollectingNameClassPairCallbackHandler handler = new MappingCollectingNameClassPairCallbackHandler( mapper); list(base, handler); return handler.getList(); }
public List search(Name base, String filter, SearchControls controls, ContextMapper mapper) { return search(base, filter, controls, mapper, new NullDirContextProcessor()); }
public List listBindings(Name base, ContextMapper mapper) { ContextMapperCallbackHandler handler = new ContextMapperCallbackHandler( mapper); listBindings(base, handler); return handler.getList(); }