-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Eliminated usage of Guava and Commons-Lang libraries
- Loading branch information
1 parent
d2944a9
commit 7cd583c
Showing
27 changed files
with
152 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 9 additions & 17 deletions
26
...pring/src/main/java/org/unbrokendome/jsonwebtoken/spring/io/Base64DecodingByteSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,30 @@ | ||
package org.unbrokendome.jsonwebtoken.spring.io; | ||
|
||
import com.google.common.io.ByteSource; | ||
import com.google.common.io.CharSource; | ||
import org.unbrokendome.jsonwebtoken.IOSupplier; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.charset.Charset; | ||
import java.util.Base64; | ||
|
||
|
||
public final class Base64DecodingByteSource extends ByteSource { | ||
public final class Base64DecodingByteSource implements IOSupplier<byte[]> { | ||
|
||
private final ByteSource encoded; | ||
private final IOSupplier<byte[]> encoded; | ||
|
||
|
||
public Base64DecodingByteSource(ByteSource encoded) { | ||
public Base64DecodingByteSource(IOSupplier<byte[]> encoded) { | ||
this.encoded = encoded; | ||
} | ||
|
||
|
||
public Base64DecodingByteSource(CharSource encoded, Charset charset) { | ||
this(encoded.asByteSource(charset)); | ||
public Base64DecodingByteSource(IOSupplier<String> encoded, Charset charset) { | ||
this(() -> encoded.get().getBytes(charset)); | ||
} | ||
|
||
|
||
@Override | ||
public byte[] read() throws IOException { | ||
return Base64.getMimeDecoder().decode(encoded.read()); | ||
} | ||
|
||
|
||
@Override | ||
public InputStream openStream() throws IOException { | ||
InputStream encodedStream = encoded.openStream(); | ||
return Base64.getDecoder().wrap(encodedStream); | ||
public byte[] get() throws IOException { | ||
byte[] encodedBytes = encoded.get(); | ||
return Base64.getMimeDecoder().decode(encodedBytes); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ing/src/main/java/org/unbrokendome/jsonwebtoken/spring/io/ResourceBinaryDataSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.unbrokendome.jsonwebtoken.spring.io; | ||
|
||
import org.springframework.core.io.Resource; | ||
import org.springframework.util.StreamUtils; | ||
import org.unbrokendome.jsonwebtoken.IOSupplier; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
|
||
public class ResourceBinaryDataSupplier implements IOSupplier<byte[]> { | ||
|
||
private final Resource resource; | ||
|
||
|
||
public ResourceBinaryDataSupplier(Resource resource) { | ||
this.resource = resource; | ||
} | ||
|
||
|
||
@Override | ||
public byte[] get() throws IOException { | ||
try (InputStream input = resource.getInputStream()) { | ||
return StreamUtils.copyToByteArray(input); | ||
} | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
...ring/src/main/java/org/unbrokendome/jsonwebtoken/spring/io/ResourceByteSourceAdapter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
jwt/src/main/java/org/unbrokendome/jsonwebtoken/IOSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.unbrokendome.jsonwebtoken; | ||
|
||
import java.io.IOException; | ||
|
||
|
||
/** | ||
* Represents a supplier of results which involves some I/O operation. | ||
* | ||
* <p>Similar to {@link java.util.function.Supplier}, but the {@link #get()} method may throw an | ||
* {@link IOException}. | ||
* | ||
* @param <T> the type of results supplied by this supplier | ||
*/ | ||
@FunctionalInterface | ||
public interface IOSupplier<T> { | ||
|
||
T get() throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.