private final class KerberosEndpoint.ConnectionImpl extends KerberosUtil.Connection implements Connection
Modifier and Type | Field and Description |
---|---|
private InputStream |
istream
InputStream this connection will provide to the upper layer
|
private static int |
KRB_AP_ERR_REPEAT
Kerberos error code defined in RFC1510 (Request is a replay)
|
private OutputStream |
ostream
OutputStream this connection will provide to the upper layer
|
clientPrincipal, connectionLogger, dis, doDelegation, doEncryption, dos, gssContext, INTEGRITY_QOP, PRIVACY_QOP, sock
Constructor and Description |
---|
KerberosEndpoint.ConnectionImpl(Socket sock,
KerberosUtil.Config config)
Establish a connection to server.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
checkConnectPermission()
Check whether the caller has sufficient permissions to reuse the
socket that this connection has connected with.
|
private void |
establishContext()
Exchange handshake messages with server to establish the
session or context of the connection.
|
SocketChannel |
getChannel()
Returns a socket channel that performs I/O on this connection,
or
null if no socket channel is available. |
(package private) KerberosEndpoint |
getEndpoint()
Get the enclosing endpoint instance
|
InputStream |
getInputStream()
Returns an input stream that reads data from this connection.
|
OutputStream |
getOutputStream()
Returns an output stream that writes data to this connection.
|
InvocationConstraints |
getUnfulfilledConstraints(OutboundRequestHandle handle)
Implements
OutboundRequest.getUnfulfilledConstraints for a request with
the specified handle. |
void |
populateContext(OutboundRequestHandle handle,
Collection context)
Populates the supplied collection with context information
representing a request with the specified handle.
|
IOException |
readResponseData(OutboundRequestHandle handle,
InputStream in)
Reads from the specified stream any per-response data required
by this connection for a request with the specified handle.
|
(package private) boolean |
satisfies(KerberosUtil.Config config)
Check whether this connection can satisfy the requirements
specified by the given configuration.
|
(package private) boolean |
switchTo(KerberosUtil.Config config)
Switch an idle connection to satisfy the given
configuration.
|
String |
toString()
Returns a string representation of this connection.
|
void |
writeRequestData(OutboundRequestHandle handle,
OutputStream out)
Writes to the specified stream any per-request data required by
this connection for a request with the specified handle.
|
close, flush, read, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close
private static final int KRB_AP_ERR_REPEAT
private InputStream istream
private OutputStream ostream
KerberosEndpoint.ConnectionImpl(Socket sock, KerberosUtil.Config config) throws IOException
sock
- socket over which the connection traffic will
be carriedconfig
- a configuration object that specifies how the
connection should be setupIOException
- if the connection establishment
handshake failspublic OutputStream getOutputStream() throws IOException
Connection
getOutputStream
in interface Connection
IOException
- if an I/O exception occurspublic InputStream getInputStream() throws IOException
Connection
getInputStream
in interface Connection
IOException
- if an I/O exception occurspublic SocketChannel getChannel()
Connection
null
if no socket channel is available. If a
non-null
socket channel is returned, it is
connected.getChannel
in interface Connection
null
public void populateContext(OutboundRequestHandle handle, Collection context)
Connection
OutboundRequest.populateContext
for such requests; the context
may also be populated by the connection manager.populateContext
in interface Connection
handle
- the handle for the requestcontext
- the context collection to populatepublic InvocationConstraints getUnfulfilledConstraints(OutboundRequestHandle handle)
Connection
OutboundRequest.getUnfulfilledConstraints
for a request with
the specified handle.getUnfulfilledConstraints
in interface Connection
handle
- the handle for the requestpublic void writeRequestData(OutboundRequestHandle handle, OutputStream out)
Connection
This method is invoked by ConnectionManager
with the request output stream of the OutboundRequest
that it creates for the request. This method can be used, for
example, to convey per-request information about delegation,
client authentication, or client privileges.
There may be multiple requests in progress concurrently over
this connection, and data written to the specified stream may
be buffered and multiplexed with data from other requests
before being written to this connection's underlying output
stream. Therefore, this method should only write data to the
specified stream and must not read any data from this
connection's underlying input stream; data can, however, be
subsequently read with readResponseData
.
writeRequestData
in interface Connection
handle
- the handle for the requestout
- the request output stream of the requestpublic IOException readResponseData(OutboundRequestHandle handle, InputStream in)
Connection
This method returns null
if the information
read (if any) indicates that the constraints are satisfied, and
it returns an exception if the constraints could not be
satisfied. If an exception is returned rather than thrown, the
delivery status of a corresponding OutboundRequest
will
be false
.
This method is invoked by ConnectionManager
with the response input stream of the
OutboundRequest
that it creates for the request
and the same handle that was passed to writeRequestData
. This method can be used to read information
produced by ServerConnection.processRequestData
in response to the
information sent by writeRequestData
.
There may be multiple requests in progress concurrently over this connection, and data read from the specified stream may have been buffered and multiplexed with data from other requests being read from this connection's underlying input stream. Therefore, this method should only read data from the specified stream and must not write any data to this connection's underlying output stream.
readResponseData
in interface Connection
handle
- the handle for the requestin
- the response input stream of the requestnull
if the constraints are satisfied, or
an exception if the constraints could not be satisfiedpublic String toString()
boolean satisfies(KerberosUtil.Config config)
void checkConnectPermission()
boolean switchTo(KerberosUtil.Config config)
config
- target configurationKerberosEndpoint getEndpoint()
private void establishContext() throws IOException, GSSException
IOException
GSSException
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.