Package net.shibboleth.shared.io

# Class SizeLimitedInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.shibboleth.shared.io.SizeLimitedInputStream

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class SizeLimitedInputStream extends FilterInputStream
An specialization of `FilterInputStream` which restricts the size of the stream to a specified number of bytes.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final long`
`maxSize`
The max size allowed.
`private long`
`totalRead`
Tracker of number of bytes read.

### Fields inherited from class java.io.FilterInputStream

`in`

## Constructor Summary

Constructors
Constructor
Description
`SizeLimitedInputStream(InputStream in, long maxAllowedSize)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`int`
`read()`
`int`
`read(byte[] b, int off, int len)`

### Methods inherited from class java.io.FilterInputStream

`available, close, mark, markSupported, read, reset, skip`

### Methods inherited from class java.io.InputStream

`nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### maxSize

private final long maxSize
The max size allowed.

### totalRead

private long totalRead
Tracker of number of bytes read.

## Constructor Details

### SizeLimitedInputStream

public SizeLimitedInputStream(@Nonnull InputStream in, long maxAllowedSize)
Constructor.

Parameters:
  `in` - the wrapped input stream
  `maxAllowedSize` - the max allowed size in bytes

## Method Details

### read

public int read() throws IOException

Overrides:
  `read` in class `FilterInputStream`
Throws:
  `IOException`

### read

public int read(byte[] b, int off, int len) throws IOException

Overrides:
  `read` in class `FilterInputStream`
Throws:
  `IOException`