keycloak-federation
公開メンバ関数 | 関数 | 非公開メンバ関数 | 非公開変数類 | 全メンバ一覧
cx.ath.matthew.unix.UnixSocket クラス
cx.ath.matthew.unix.UnixSocket 連携図
Collaboration graph

公開メンバ関数

 UnixSocket ()
 
 UnixSocket (UnixSocketAddress address) throws IOException
 
 UnixSocket (String address) throws IOException
 
void connect (UnixSocketAddress address) throws IOException
 
void connect (String address) throws IOException
 
void finalize ()
 
synchronized void close () throws IOException
 
InputStream getInputStream ()
 
OutputStream getOutputStream ()
 
UnixSocketAddress getAddress ()
 
void sendCredentialByte (byte data) throws IOException
 
byte recvCredentialByte () throws IOException
 
boolean getPassCred ()
 
int getPeerUID ()
 
int getPeerGID ()
 
int getPeerPID ()
 
void setPassCred (boolean enable) throws IOException
 
boolean getBlocking ()
 
void setBlocking (boolean enable)
 
boolean isClosed ()
 
boolean isConnected ()
 
boolean isInputShutdown ()
 
boolean isOutputShutdown ()
 
void shutdownInput ()
 
void shutdownOutput ()
 
void setSoTimeout (int timeout)
 

関数

 UnixSocket (int sock, UnixSocketAddress address)
 

非公開メンバ関数

native void native_set_pass_cred (int sock, boolean passcred) throws IOException
 
native int native_connect (String address, boolean abs) throws IOException
 
native void native_close (int sock) throws IOException
 
native int native_getPID (int sock)
 
native int native_getUID (int sock)
 
native int native_getGID (int sock)
 
native void native_send_creds (int sock, byte data) throws IOException
 
native byte native_recv_creds (int sock, int[] creds) throws IOException
 

非公開変数類

UnixSocketAddress address = null
 
USOutputStream os = null
 
USInputStream is = null
 
boolean closed = false
 
boolean connected = false
 
boolean passcred = false
 
int sock = 0
 
boolean blocking = true
 
int uid = -1
 
int pid = -1
 
int gid = -1
 

詳解

Represents a UnixSocket.

構築子と解体子

◆ UnixSocket() [1/4]

cx.ath.matthew.unix.UnixSocket.UnixSocket ( int  sock,
UnixSocketAddress  address 
)
inlinepackage
68  {
69  this.sock = sock;
70  this.address = address;
71  this.connected = true;
72  this.os = new USOutputStream(sock, this);
73  this.is = new USInputStream(sock, this);
74  }
USInputStream is
Definition: UnixSocket.java:58
UnixSocketAddress address
Definition: UnixSocket.java:56
int sock
Definition: UnixSocket.java:62
USOutputStream os
Definition: UnixSocket.java:57
boolean connected
Definition: UnixSocket.java:60

◆ UnixSocket() [2/4]

cx.ath.matthew.unix.UnixSocket.UnixSocket ( )
inline

Create an unconnected socket.

79  {
80  }

◆ UnixSocket() [3/4]

cx.ath.matthew.unix.UnixSocket.UnixSocket ( UnixSocketAddress  address) throws IOException
inline

Create a socket connected to the given address.

引数
addressThe Unix Socket address to connect to
87  {
89  }
UnixSocketAddress address
Definition: UnixSocket.java:56
void connect(UnixSocketAddress address)
Definition: UnixSocket.java:105

◆ UnixSocket() [4/4]

cx.ath.matthew.unix.UnixSocket.UnixSocket ( String  address) throws IOException
inline

Create a socket connected to the given address.

引数
addressThe Unix Socket address to connect to
96  {
97  this(new UnixSocketAddress(address));
98  }
UnixSocketAddress address
Definition: UnixSocket.java:56

関数詳解

◆ close()

synchronized void cx.ath.matthew.unix.UnixSocket.close ( ) throws IOException
inline

Closes the connection.

135  {
136  if (Debug.debug) Debug.print(Debug.INFO, "Closing socket");
138  sock = 0;
139  this.closed = true;
140  this.connected = false;
141  os = null;
142  is = null;
143  }
USInputStream is
Definition: UnixSocket.java:58
int sock
Definition: UnixSocket.java:62
USOutputStream os
Definition: UnixSocket.java:57
boolean connected
Definition: UnixSocket.java:60
native void native_close(int sock)
boolean closed
Definition: UnixSocket.java:59

◆ connect() [1/2]

void cx.ath.matthew.unix.UnixSocket.connect ( UnixSocketAddress  address) throws IOException
inline

Connect the socket to this address.

引数
addressThe Unix Socket address to connect to
105  {
106  if (connected) close();
108  this.os = new USOutputStream(this.sock, this);
109  this.is = new USInputStream(this.sock, this);
110  this.address = address;
111  this.connected = true;
112  this.closed = false;
113  this.is.setBlocking(blocking);
114  }
synchronized void close()
Definition: UnixSocket.java:135
USInputStream is
Definition: UnixSocket.java:58
String path
Definition: UnixSocketAddress.java:33
UnixSocketAddress address
Definition: UnixSocket.java:56
boolean abs
Definition: UnixSocketAddress.java:34
boolean blocking
Definition: UnixSocket.java:63
int sock
Definition: UnixSocket.java:62
USOutputStream os
Definition: UnixSocket.java:57
void setBlocking(boolean enable)
Definition: USInputStream.java:87
boolean connected
Definition: UnixSocket.java:60
native int native_connect(String address, boolean abs)
boolean closed
Definition: UnixSocket.java:59

◆ connect() [2/2]

void cx.ath.matthew.unix.UnixSocket.connect ( String  address) throws IOException
inline

Connect the socket to this address.

引数
addressThe Unix Socket address to connect to
121  {
122  connect(new UnixSocketAddress(address));
123  }
UnixSocketAddress address
Definition: UnixSocket.java:56
void connect(UnixSocketAddress address)
Definition: UnixSocket.java:105

◆ finalize()

void cx.ath.matthew.unix.UnixSocket.finalize ( )
inline
125  {
126  try {
127  close();
128  } catch (IOException IOe) {
129  }
130  }
synchronized void close()
Definition: UnixSocket.java:135

◆ getAddress()

UnixSocketAddress cx.ath.matthew.unix.UnixSocket.getAddress ( )
inline

Returns the address this socket is connected to. Returns null if the socket is unconnected.

戻り値
The UnixSocketAddress the socket is connected to
169  {
170  return address;
171  }
UnixSocketAddress address
Definition: UnixSocket.java:56

◆ getBlocking()

boolean cx.ath.matthew.unix.UnixSocket.getBlocking ( )
inline

Get the blocking mode.

戻り値
true if reads are blocking.
参照
setBlocking
274  {
275  return blocking;
276  }
boolean blocking
Definition: UnixSocket.java:63

◆ getInputStream()

InputStream cx.ath.matthew.unix.UnixSocket.getInputStream ( )
inline

Returns an InputStream for reading from the socket.

戻り値
An InputStream connected to this socket.
150  {
151  return is;
152  }
USInputStream is
Definition: UnixSocket.java:58

◆ getOutputStream()

OutputStream cx.ath.matthew.unix.UnixSocket.getOutputStream ( )
inline

Returns an OutputStream for writing to the socket.

戻り値
An OutputStream connected to this socket.
159  {
160  return os;
161  }
USOutputStream os
Definition: UnixSocket.java:57

◆ getPassCred()

boolean cx.ath.matthew.unix.UnixSocket.getPassCred ( )
inline

Get the credential passing status. (only effective on linux)

戻り値
The current status of credential passing.
参照
setPassCred
210  {
211  return passcred;
212  }
boolean passcred
Definition: UnixSocket.java:61

◆ getPeerGID()

int cx.ath.matthew.unix.UnixSocket.getPeerGID ( )
inline

Return the gid of the remote process. Some data must have been received on the socket to do this. Either setPassCred must be called on Linux first, or recvCredentialByte on BSD.

戻り値
the GID or -1 if it is not available
236  {
237  if (-1 == gid)
239  return gid;
240  }
int sock
Definition: UnixSocket.java:62
native int native_getGID(int sock)
int gid
Definition: UnixSocket.java:66

◆ getPeerPID()

int cx.ath.matthew.unix.UnixSocket.getPeerPID ( )
inline

Return the pid of the remote process. Some data must have been received on the socket to do this. Either setPassCred must be called on Linux first, or recvCredentialByte on BSD.

戻り値
the PID or -1 if it is not available
250  {
251  if (-1 == pid)
253  return pid;
254  }
native int native_getPID(int sock)
int sock
Definition: UnixSocket.java:62
int pid
Definition: UnixSocket.java:65

◆ getPeerUID()

int cx.ath.matthew.unix.UnixSocket.getPeerUID ( )
inline

Return the uid of the remote process. Some data must have been received on the socket to do this. Either setPassCred must be called on Linux first, or recvCredentialByte on BSD.

戻り値
the UID or -1 if it is not available
222  {
223  if (-1 == uid)
225  return uid;
226  }
native int native_getUID(int sock)
int sock
Definition: UnixSocket.java:62
int uid
Definition: UnixSocket.java:64

◆ isClosed()

boolean cx.ath.matthew.unix.UnixSocket.isClosed ( )
inline

Check the socket status.

戻り値
true if closed.
293  {
294  return closed;
295  }
boolean closed
Definition: UnixSocket.java:59

◆ isConnected()

boolean cx.ath.matthew.unix.UnixSocket.isConnected ( )
inline

Check the socket status.

戻り値
true if connected.
302  {
303  return connected;
304  }
boolean connected
Definition: UnixSocket.java:60

◆ isInputShutdown()

boolean cx.ath.matthew.unix.UnixSocket.isInputShutdown ( )
inline

Check the socket status.

戻り値
true if the input stream has been shutdown
311  {
312  return is.isClosed();
313  }
USInputStream is
Definition: UnixSocket.java:58
boolean isClosed()
Definition: USInputStream.java:79

◆ isOutputShutdown()

boolean cx.ath.matthew.unix.UnixSocket.isOutputShutdown ( )
inline

Check the socket status.

戻り値
true if the output stream has been shutdown
320  {
321  return os.isClosed();
322  }
USOutputStream os
Definition: UnixSocket.java:57
boolean isClosed()
Definition: USOutputStream.java:71

◆ native_close()

native void cx.ath.matthew.unix.UnixSocket.native_close ( int  sock) throws IOException
private

◆ native_connect()

native int cx.ath.matthew.unix.UnixSocket.native_connect ( String  address,
boolean  abs 
) throws IOException
private

◆ native_getGID()

native int cx.ath.matthew.unix.UnixSocket.native_getGID ( int  sock)
private

◆ native_getPID()

native int cx.ath.matthew.unix.UnixSocket.native_getPID ( int  sock)
private

◆ native_getUID()

native int cx.ath.matthew.unix.UnixSocket.native_getUID ( int  sock)
private

◆ native_recv_creds()

native byte cx.ath.matthew.unix.UnixSocket.native_recv_creds ( int  sock,
int []  creds 
) throws IOException
private

◆ native_send_creds()

native void cx.ath.matthew.unix.UnixSocket.native_send_creds ( int  sock,
byte  data 
) throws IOException
private

◆ native_set_pass_cred()

native void cx.ath.matthew.unix.UnixSocket.native_set_pass_cred ( int  sock,
boolean  passcred 
) throws IOException
private

◆ recvCredentialByte()

byte cx.ath.matthew.unix.UnixSocket.recvCredentialByte ( ) throws IOException
inline

Receive a single byte of data, with credentials. (Works on BSDs)

引数
dataThe byte of data to send.
参照
getPeerUID
getPeerPID
getPeerGID
193  {
194  if (!connected) throw new NotConnectedException();
195  int[] creds = new int[]{-1, -1, -1};
196  byte data = native_recv_creds(sock, creds);
197  pid = creds[0];
198  uid = creds[1];
199  gid = creds[2];
200  return data;
201  }
native byte native_recv_creds(int sock, int[] creds)
int sock
Definition: UnixSocket.java:62
int pid
Definition: UnixSocket.java:65
boolean connected
Definition: UnixSocket.java:60
int gid
Definition: UnixSocket.java:66
int uid
Definition: UnixSocket.java:64

◆ sendCredentialByte()

void cx.ath.matthew.unix.UnixSocket.sendCredentialByte ( byte  data) throws IOException
inline

Send a single byte of data with credentials. (Works on BSDs)

引数
dataThe byte of data to send.
179  {
180  if (!connected) throw new NotConnectedException();
181  native_send_creds(sock, data);
182  }
native void native_send_creds(int sock, byte data)
int sock
Definition: UnixSocket.java:62
boolean connected
Definition: UnixSocket.java:60

◆ setBlocking()

void cx.ath.matthew.unix.UnixSocket.setBlocking ( boolean  enable)
inline

Set the blocking mode.

引数
enableSet to false for non-blocking reads.
283  {
284  blocking = enable;
285  if (null != is) is.setBlocking(enable);
286  }
USInputStream is
Definition: UnixSocket.java:58
boolean blocking
Definition: UnixSocket.java:63
void setBlocking(boolean enable)
Definition: USInputStream.java:87

◆ setPassCred()

void cx.ath.matthew.unix.UnixSocket.setPassCred ( boolean  enable) throws IOException
inline

Set the credential passing status. (Only does anything on linux, for other OS, you need to use send/recv credentials)

引数
enableSet to true for credentials to be passed.
263  {
264  native_set_pass_cred(sock, enable);
265  passcred = enable;
266  }
int sock
Definition: UnixSocket.java:62
boolean passcred
Definition: UnixSocket.java:61
native void native_set_pass_cred(int sock, boolean passcred)

◆ setSoTimeout()

void cx.ath.matthew.unix.UnixSocket.setSoTimeout ( int  timeout)
inline

Set timeout of read requests.

343  {
344  is.setSoTimeout(timeout);
345  }
USInputStream is
Definition: UnixSocket.java:58
void setSoTimeout(int timeout)
Definition: USInputStream.java:91

◆ shutdownInput()

void cx.ath.matthew.unix.UnixSocket.shutdownInput ( )
inline

Shuts down the input stream. Subsequent reads on the associated InputStream will fail.

328  {
329  is.closed = true;
330  }
USInputStream is
Definition: UnixSocket.java:58
boolean closed
Definition: USInputStream.java:38

◆ shutdownOutput()

void cx.ath.matthew.unix.UnixSocket.shutdownOutput ( )
inline

Shuts down the output stream. Subsequent writes to the associated OutputStream will fail.

336  {
337  os.closed = true;
338  }
USOutputStream os
Definition: UnixSocket.java:57
boolean closed
Definition: USOutputStream.java:38

メンバ詳解

◆ address

UnixSocketAddress cx.ath.matthew.unix.UnixSocket.address = null
private

◆ blocking

boolean cx.ath.matthew.unix.UnixSocket.blocking = true
private

◆ closed

boolean cx.ath.matthew.unix.UnixSocket.closed = false
private

◆ connected

boolean cx.ath.matthew.unix.UnixSocket.connected = false
private

◆ gid

int cx.ath.matthew.unix.UnixSocket.gid = -1
private

◆ is

USInputStream cx.ath.matthew.unix.UnixSocket.is = null
private

◆ os

USOutputStream cx.ath.matthew.unix.UnixSocket.os = null
private

◆ passcred

boolean cx.ath.matthew.unix.UnixSocket.passcred = false
private

◆ pid

int cx.ath.matthew.unix.UnixSocket.pid = -1
private

◆ sock

int cx.ath.matthew.unix.UnixSocket.sock = 0
private

◆ uid

int cx.ath.matthew.unix.UnixSocket.uid = -1
private

このクラス詳解は次のファイルから抽出されました: