|
1 |
| package org.acegisecurity.util; |
|
2 |
| |
|
3 |
| import org.springframework.core.io.AbstractResource; |
|
4 |
| |
|
5 |
| import java.io.ByteArrayInputStream; |
|
6 |
| import java.io.InputStream; |
|
7 |
| import java.io.IOException; |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| public class InMemoryResource extends AbstractResource { |
|
20 |
| |
|
21 |
| ByteArrayInputStream in; |
|
22 |
| String description; |
|
23 |
| |
|
24 |
0
| public InMemoryResource(byte[] source) {
|
|
25 |
0
| this(source, null);
|
|
26 |
| } |
|
27 |
| |
|
28 |
0
| public InMemoryResource(byte[] source, String description) {
|
|
29 |
0
| in = new ByteArrayInputStream(source);
|
|
30 |
0
| this.description = description;
|
|
31 |
| } |
|
32 |
| |
|
33 |
0
| public String getDescription() {
|
|
34 |
0
| return description == null ? in.toString() : description;
|
|
35 |
| } |
|
36 |
| |
|
37 |
0
| public InputStream getInputStream() throws IOException {
|
|
38 |
0
| return in;
|
|
39 |
| } |
|
40 |
| } |