Skip to content

Instantly share code, notes, and snippets.

View dfish3r's full-sized avatar

Daniel Fisher dfish3r

View GitHub Profile
@dfish3r
dfish3r / LdaptiveConcurrent.java
Created August 15, 2019 17:57
Ldaptive v2 Concurrency Test Client
import java.time.Duration;
import java.util.*;
import java.util.concurrent.*;
import org.ldaptive.*;
import org.ldaptive.auth.*;
import org.ldaptive.pool.*;
import org.ldaptive.ssl.*;
public final class LdaptiveConcurrent
{
import org.ldaptive.auth.AddControlAuthenticationRequestHandler;
import org.ldaptive.control.RequestControl;
import org.ldaptive.control.SessionTrackingControl;
public class SessionTrackingAuthenticationRequestHandler extends AddControlAuthenticationRequestHandler
{
private final UserRequestData requestData;
public SessionTrackingAuthenticationRequestHandler()
{
@dfish3r
dfish3r / ActiveDirectoryAuthenticationHandler.java
Created May 26, 2017 16:33
Ldaptive AuthenticationHandler for Active Directory
import org.ldaptive.LdapException;
import org.ldaptive.auth.AuthenticationCriteria;
import org.ldaptive.auth.AuthenticationHandler;
import org.ldaptive.auth.AuthenticationHandlerResponse;
/**
* Provides an LDAP authentication implementation that wraps the invocation of another handler and then inspects the
* response. If the response result is false and it contains the {@link ActiveDirectoryAccountState.Error#ACCOUNT_EXPIRED}
* error, then the response result is changed from false to true.
*
public class ShibSSLContextInitializer implements SSLContextInitializer {
@Override public SSLContext initSSLContext(String protocol) throws GeneralSecurityException {
final SSLContext ctx = SSLContext.getInstance(protocol);
ctx.init(getKeyManagers(), getTrustManagers(), null);
return ctx;
}
@Override public TrustManager[] getTrustManagers() throws GeneralSecurityException {
return new TrustManager[0]; // expose your trust managers here