keycloak
公開メンバ関数 | 非公開変数類 | 全メンバ一覧
org.keycloak.common.util.Base64.OutputStream クラス
org.keycloak.common.util.Base64.OutputStream の継承関係図
Inheritance graph
org.keycloak.common.util.Base64.OutputStream 連携図
Collaboration graph

公開メンバ関数

 OutputStream (java.io.OutputStream out)
 
 OutputStream (java.io.OutputStream out, int options)
 
void write (int theByte) throws java.io.IOException
 
void write (byte[] theBytes, int off, int len) throws java.io.IOException
 
void flushBase64 () throws java.io.IOException
 
void close () throws java.io.IOException
 
void suspendEncoding () throws java.io.IOException
 
void resumeEncoding ()
 

非公開変数類

boolean encode
 
int position
 
byte [] buffer
 
int bufferLength
 
int lineLength
 
boolean breakLines
 
byte [] b4
 
boolean suspendEncoding
 
int options
 
byte [] decodabet
 

詳解

A Base64.OutputStream will write data to another java.io.OutputStream, given in the constructor, and encode/decode to/from Base64 notation on the fly.

参照
Base64
から
1.3

構築子と解体子

◆ OutputStream() [1/2]

org.keycloak.common.util.Base64.OutputStream.OutputStream ( java.io.OutputStream  out)
inline

Constructs a Base64.OutputStream in ENCODE mode.

引数
outthe java.io.OutputStream to which data will be written.
から
1.3
1547  {
1548  this( out, ENCODE );
1549  } // end constructor
static final int ENCODE
Definition: Base64.java:160

◆ OutputStream() [2/2]

org.keycloak.common.util.Base64.OutputStream.OutputStream ( java.io.OutputStream  out,
int  options 
)
inline

Constructs a Base64.OutputStream in either ENCODE or DECODE mode.

Valid options:

  ENCODE or DECODE: Encode or Decode as data is read.
  DO_BREAK_LINES: don't break lines at 76 characters
    (only meaningful when encoding)

Example: new Base64.OutputStream( out, Base64.ENCODE )

引数
outthe java.io.OutputStream to which data will be written.
optionsSpecified options.
参照
Base64::ENCODE
Base64::DECODE
Base64::DO_BREAK_LINES
から
1.3
1571  {
1572  super( out );
1573  this.breakLines = (options & DO_BREAK_LINES) != 0;
1574  this.encode = (options & ENCODE) != 0;
1575  this.bufferLength = encode ? 3 : 4;
1576  this.buffer = new byte[ bufferLength ];
1577  this.position = 0;
1578  this.lineLength = 0;
1579  this.suspendEncoding = false;
1580  this.b4 = new byte[4];
1581  this.options = options;
1582  this.decodabet = getDecodabet(options);
1583  } // end constructor
boolean encode
Definition: Base64.java:1530
int lineLength
Definition: Base64.java:1534
static final int DO_BREAK_LINES
Definition: Base64.java:175
static final int ENCODE
Definition: Base64.java:160
byte [] decodabet
Definition: Base64.java:1539
int options
Definition: Base64.java:1538
byte [] b4
Definition: Base64.java:1536
static final byte [] getDecodabet(int options)
Definition: Base64.java:430
byte [] buffer
Definition: Base64.java:1532
int position
Definition: Base64.java:1531
void suspendEncoding()
Definition: Base64.java:1717
int bufferLength
Definition: Base64.java:1533
boolean breakLines
Definition: Base64.java:1535

関数詳解

◆ close()

void org.keycloak.common.util.Base64.OutputStream.close ( ) throws java.io.IOException
inline

Flushes and closes (I think, in the superclass) the stream.

から
1.3
1695  {
1696  // 1. Ensure that pending characters are written
1697  flushBase64();
1698 
1699  // 2. Actually close the stream
1700  // Base class both flushes and closes.
1701  super.close();
1702 
1703  buffer = null;
1704  out = null;
1705  } // end close
void flushBase64()
Definition: Base64.java:1675
byte [] buffer
Definition: Base64.java:1532

◆ flushBase64()

void org.keycloak.common.util.Base64.OutputStream.flushBase64 ( ) throws java.io.IOException
inline

Method added by PHIL. [Thanks, PHIL. -Rob] This pads the buffer without closing the stream.

例外
java.io.IOExceptionif there's an error.
1675  {
1676  if( position > 0 ) {
1677  if( encode ) {
1678  out.write( encode3to4( b4, buffer, position, options ) );
1679  position = 0;
1680  } // end if: encoding
1681  else {
1682  throw new java.io.IOException( "Base64 input not properly padded." );
1683  } // end else: decoding
1684  } // end if: buffer partially full
1685 
1686  } // end flush
boolean encode
Definition: Base64.java:1530
static byte [] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options)
Definition: Base64.java:466
int options
Definition: Base64.java:1538
byte [] b4
Definition: Base64.java:1536
byte [] buffer
Definition: Base64.java:1532
int position
Definition: Base64.java:1531

◆ resumeEncoding()

void org.keycloak.common.util.Base64.OutputStream.resumeEncoding ( )
inline

Resumes encoding of the stream. May be helpful if you need to embed a piece of base64-encoded data in a stream.

から
1.5.1
1730  {
1731  this.suspendEncoding = false;
1732  } // end resumeEncoding
void suspendEncoding()
Definition: Base64.java:1717

◆ suspendEncoding()

void org.keycloak.common.util.Base64.OutputStream.suspendEncoding ( ) throws java.io.IOException
inline

Suspends encoding of the stream. May be helpful if you need to embed a piece of base64-encoded data in a stream.

例外
java.io.IOExceptionif there's an error flushing
から
1.5.1
1717  {
1718  flushBase64();
1719  this.suspendEncoding = true;
1720  } // end suspendEncoding
void flushBase64()
Definition: Base64.java:1675
void suspendEncoding()
Definition: Base64.java:1717

◆ write() [1/2]

void org.keycloak.common.util.Base64.OutputStream.write ( int  theByte) throws java.io.IOException
inline

Writes the byte to the output stream after converting to/from Base64 notation. When encoding, bytes are buffered three at a time before the output stream actually gets a write() call. When decoding, bytes are buffered four at a time.

引数
theBytethe byte to write
から
1.3
1600  {
1601  // Encoding suspended?
1602  if( suspendEncoding ) {
1603  this.out.write( theByte );
1604  return;
1605  } // end if: supsended
1606 
1607  // Encode?
1608  if( encode ) {
1609  buffer[ position++ ] = (byte)theByte;
1610  if( position >= bufferLength ) { // Enough to encode.
1611 
1612  this.out.write( encode3to4( b4, buffer, bufferLength, options ) );
1613 
1614  lineLength += 4;
1615  if( breakLines && lineLength >= MAX_LINE_LENGTH ) {
1616  this.out.write( NEW_LINE );
1617  lineLength = 0;
1618  } // end if: end of line
1619 
1620  position = 0;
1621  } // end if: enough to output
1622  } // end if: encoding
1623 
1624  // Else, Decoding
1625  else {
1626  // Meaningful Base64 character?
1627  if( decodabet[ theByte & 0x7f ] > WHITE_SPACE_ENC ) {
1628  buffer[ position++ ] = (byte)theByte;
1629  if( position >= bufferLength ) { // Enough to output.
1630 
1631  int len = Base64.decode4to3( buffer, 0, b4, 0, options );
1632  out.write( b4, 0, len );
1633  position = 0;
1634  } // end if: enough to output
1635  } // end if: meaningful base64 character
1636  else if( decodabet[ theByte & 0x7f ] != WHITE_SPACE_ENC ) {
1637  throw new java.io.IOException( "Invalid character in Base64 data." );
1638  } // end else: not white space either
1639  } // end else: decoding
1640  } // end write
boolean encode
Definition: Base64.java:1530
static final byte NEW_LINE
Definition: Base64.java:207
int lineLength
Definition: Base64.java:1534
Base64()
Definition: Base64.java:443
static byte [] encode3to4(byte[] b4, byte[] threeBytes, int numSigBytes, int options)
Definition: Base64.java:466
byte [] decodabet
Definition: Base64.java:1539
int options
Definition: Base64.java:1538
byte [] b4
Definition: Base64.java:1536
byte [] buffer
Definition: Base64.java:1532
static final byte WHITE_SPACE_ENC
Definition: Base64.java:214
int position
Definition: Base64.java:1531
void suspendEncoding()
Definition: Base64.java:1717
int bufferLength
Definition: Base64.java:1533
static final int MAX_LINE_LENGTH
Definition: Base64.java:199
boolean breakLines
Definition: Base64.java:1535

◆ write() [2/2]

void org.keycloak.common.util.Base64.OutputStream.write ( byte []  theBytes,
int  off,
int  len 
) throws java.io.IOException
inline

Calls write(int) repeatedly until len bytes are written.

引数
theBytesarray from which to read bytes
offoffset for array
lenmax number of bytes to read into array
から
1.3
1655  {
1656  // Encoding suspended?
1657  if( suspendEncoding ) {
1658  this.out.write( theBytes, off, len );
1659  return;
1660  } // end if: supsended
1661 
1662  for( int i = 0; i < len; i++ ) {
1663  write( theBytes[ off + i ] );
1664  } // end for: each byte written
1665 
1666  } // end write
void write(int theByte)
Definition: Base64.java:1599
void suspendEncoding()
Definition: Base64.java:1717

メンバ詳解

◆ b4

byte [] org.keycloak.common.util.Base64.OutputStream.b4
private

◆ breakLines

boolean org.keycloak.common.util.Base64.OutputStream.breakLines
private

◆ buffer

byte [] org.keycloak.common.util.Base64.OutputStream.buffer
private

◆ bufferLength

int org.keycloak.common.util.Base64.OutputStream.bufferLength
private

◆ decodabet

byte [] org.keycloak.common.util.Base64.OutputStream.decodabet
private

◆ encode

boolean org.keycloak.common.util.Base64.OutputStream.encode
private

◆ lineLength

int org.keycloak.common.util.Base64.OutputStream.lineLength
private

◆ options

int org.keycloak.common.util.Base64.OutputStream.options
private

◆ position

int org.keycloak.common.util.Base64.OutputStream.position
private

◆ suspendEncoding

boolean org.keycloak.common.util.Base64.OutputStream.suspendEncoding
private

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