1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 module hunt.shiro.util.ByteSource;
20 
21 // import java.io.File;
22 // import java.io.InputStream;
23 
24 /**
25  * A {@code ByteSource} wraps a byte array and provides additional encoding operations.  Most users will find the
26  * {@link Util} inner class sufficient to construct ByteSource instances.
27  *
28  * @since 1.0
29  */
30 interface ByteSource {
31 
32     /**
33      * Returns the wrapped byte array.
34      *
35      * @return the wrapped byte array.
36      */
37     byte[] getBytes();
38 
39     /**
40      * Returns the <a href="http://en.wikipedia.org/wiki/Hexadecimal">Hex</a>-formatted string representation of the
41      * underlying wrapped byte array.
42      *
43      * @return the <a href="http://en.wikipedia.org/wiki/Hexadecimal">Hex</a>-formatted string representation of the
44      *         underlying wrapped byte array.
45      */
46     string toHex();
47 
48     /**
49      * Returns the <a href="http://en.wikipedia.org/wiki/Base64">Base 64</a>-formatted string representation of the
50      * underlying wrapped byte array.
51      *
52      * @return the <a href="http://en.wikipedia.org/wiki/Base64">Base 64</a>-formatted string representation of the
53      *         underlying wrapped byte array.
54      */
55     string toBase64();
56 
57     /**
58      * Returns {@code true} if the underlying wrapped byte array is null or empty (zero length), {@code false}
59      * otherwise.
60      *
61      * @return {@code true} if the underlying wrapped byte array is null or empty (zero length), {@code false}
62      *         otherwise.
63      * @since 1.2
64      */
65     bool isEmpty();
66 }