Source:
<code>private AuthenticationInfo queryForAuthenticationInfoSAM( AuthenticationToken token, LdapContextFactory ldapContextFactory ) throws NamingException { Object principal = token.getPrincipal(); Object credentials = token.getCredentials(); LdapContext ctx = null; try { ctx = useStartTls ? getSystemLdapContextUsingStartTls( ldapContextFactory ) : ldapContextFactory.getSystemLdapContext(); String[] attrs = {"cn"}; SearchControls searchCtls = new SearchControls( SearchControls.SUBTREE_SCOPE, 1, 0, attrs, false, false ); Object[] searchArguments = new Object[]{principal}; String filter = "sAMAccountName={0}"; NamingEnumeration<SearchResult> search = ctx.search( userSearchBase, filter, searchArguments, searchCtls ); if ( search.hasMore() ) { final SearchResult next = search.next(); String loginUser = next.getNameInNamespace(); if ( search.hasMore() ) { securityLog.error( "More than one user matching: " + principal ); <START> throw new RuntimeException( "More than one user matching: " + principal ); <END> } else { try { LdapContext ctx2 = ldapContextFactory.getLdapContext( loginUser, credentials ); LdapUtils.closeContext( ctx2 ); } catch ( Exception ex ) { securityLog.warn( "Error in authentication for user " + loginUser, ex ); throw ex; } } } else { securityLog.warn( "No user matching: " + principal ); throw new RuntimeException( "No user matching: " + principal ); } return createAuthenticationInfo( token, principal, credentials, ctx ); } catch ( NamingException ne ) { securityLog.error( "Error in ldap name resolving", ne ); throw ne; } finally { LdapUtils.closeContext( ctx ); } }</code><technical_language>throw nicer raw RuntimeException</technical_language>

Target:
private AuthenticationInfo queryForAuthenticationInfoSAM( AuthenticationToken token, LdapContextFactory ldapContextFactory ) throws NamingException { Object principal = token.getPrincipal(); Object credentials = token.getCredentials(); LdapContext ctx = null; try { ctx = useStartTls ? getSystemLdapContextUsingStartTls( ldapContextFactory ) : ldapContextFactory.getSystemLdapContext(); String[] attrs = {"cn"}; SearchControls searchCtls = new SearchControls( SearchControls.SUBTREE_SCOPE, 1, 0, attrs, false, false ); Object[] searchArguments = new Object[]{principal}; String filter = "sAMAccountName={0}"; NamingEnumeration<SearchResult> search = ctx.search( userSearchBase, filter, searchArguments, searchCtls ); if ( search.hasMore() ) { final SearchResult next = search.next(); String loginUser = next.getNameInNamespace(); if ( search.hasMore() ) { securityLog.error( "More than one user matching: " + principal ); throw new AuthenticationException( "More than one user matching: " + principal ); } else { try { LdapContext ctx2 = ldapContextFactory.getLdapContext( loginUser, credentials ); LdapUtils.closeContext( ctx2 ); } catch ( Exception ex ) { securityLog.warn( "Error in authentication for user " + loginUser, ex ); throw ex; } } } else { securityLog.warn( "No user matching: " + principal ); throw new AuthenticationException( "No user matching: " + principal ); } return createAuthenticationInfo( token, principal, credentials, ctx ); } catch ( NamingException ne ) { securityLog.error( "Error in ldap name resolving", ne ); throw ne; } finally { LdapUtils.closeContext( ctx ); } }