Package org.ldaptive.ssl
Class HostnameVerifyingListener
- java.lang.Object
-
- org.ldaptive.ssl.HostnameVerifyingListener
-
- All Implemented Interfaces:
EventListener
,HandshakeCompletedListener
public class HostnameVerifyingListener extends Object implements HandshakeCompletedListener
Handshake completed listener that invokes a hostname verifier. If hostname verification fails, the socket is closed and the SSL session is invalidated.
-
-
Field Summary
Fields Modifier and Type Field Description private String
hostname
Hostname used in verification.private HostnameVerifier
hostnameVerifier
Hostname verifier invoked when the handshake completes.private boolean
invoked
Whether this listener has been invoked.protected Logger
logger
Logger for this class.private boolean
verified
Whether hostname verification succeeded.
-
Constructor Summary
Constructors Constructor Description HostnameVerifyingListener(HostnameVerifier verifier)
Creates a new verifying handshake completed listener.HostnameVerifyingListener(HostnameVerifier verifier, String name)
Creates a new verifying handshake completed listener.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handshakeCompleted(HandshakeCompletedEvent event)
void
peerVerified()
Throws exception if hostname verification failed.
-
-
-
Field Detail
-
logger
protected final Logger logger
Logger for this class.
-
hostnameVerifier
private final HostnameVerifier hostnameVerifier
Hostname verifier invoked when the handshake completes.
-
invoked
private boolean invoked
Whether this listener has been invoked.
-
verified
private boolean verified
Whether hostname verification succeeded.
-
hostname
private String hostname
Hostname used in verification.
-
-
Constructor Detail
-
HostnameVerifyingListener
public HostnameVerifyingListener(HostnameVerifier verifier)
Creates a new verifying handshake completed listener. Hostname will be derived from the SSL session.- Parameters:
verifier
- hostname verifier
-
HostnameVerifyingListener
public HostnameVerifyingListener(HostnameVerifier verifier, String name)
Creates a new verifying handshake completed listener.- Parameters:
verifier
- hostname verifiername
- hostname to verify
-
-
Method Detail
-
handshakeCompleted
public void handshakeCompleted(HandshakeCompletedEvent event)
- Specified by:
handshakeCompleted
in interfaceHandshakeCompletedListener
-
peerVerified
public void peerVerified() throws SSLPeerUnverifiedException
Throws exception if hostname verification failed.- Throws:
IllegalStateException
- if this listener has not been invokedSSLPeerUnverifiedException
- if the hostname failed to verify
-
-