in lang/src/main/java/org/apache/shiro/lang/util/ByteSource.java [166:193]
public static ByteSource bytes(Object source) throws IllegalArgumentException {
if (source == null) {
return null;
}
if (!isCompatible(source)) {
String msg = "Unable to heuristically acquire bytes for object of type ["
+ source.getClass().getName() + "]. If this type is indeed a byte-backed data type, you might "
+ "want to write your own ByteSource implementation to extract its bytes explicitly.";
throw new IllegalArgumentException(msg);
}
if (source instanceof byte[]) {
return bytes((byte[]) source);
} else if (source instanceof ByteSource) {
return (ByteSource) source;
} else if (source instanceof char[]) {
return bytes((char[]) source);
} else if (source instanceof String) {
return bytes((String) source);
} else if (source instanceof File) {
return bytes((File) source);
} else if (source instanceof InputStream) {
return bytes((InputStream) source);
} else {
throw new IllegalStateException("Encountered unexpected byte source. This is a bug - please notify "
+ "the Shiro developer list asap (the isCompatible implementation does not reflect this "
+ "method's implementation).");
}
}