io.jsonwebtoken.CompressionCodec Java Examples

The following examples show how to use io.jsonwebtoken.CompressionCodec. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultCompressionCodecResolver.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CompressionCodec resolveCompressionCodec(Header header) {
    String cmpAlg = getAlgorithmFromHeader(header);

    final boolean hasCompressionAlgorithm = Strings.hasText(cmpAlg);

    if (!hasCompressionAlgorithm) {
        return null;
    }
    if (CompressionCodecs.DEFLATE.getAlgorithmName().equalsIgnoreCase(cmpAlg)) {
        return CompressionCodecs.DEFLATE;
    }
    if (CompressionCodecs.GZIP.getAlgorithmName().equalsIgnoreCase(cmpAlg)) {
        return CompressionCodecs.GZIP;
    }

    throw new CompressionException("Unsupported compression algorithm '" + cmpAlg + "'");
}
 
Example #2
Source File: DefaultCompressionCodecResolver.java    From jjwt with Apache License 2.0 5 votes vote down vote up
public DefaultCompressionCodecResolver() {
    Map<String, CompressionCodec> codecMap = new HashMap<>();
    for (CompressionCodec codec : Services.loadAll(CompressionCodec.class)) {
        codecMap.put(codec.getAlgorithmName().toUpperCase(), codec);
    }

    codecMap.put(CompressionCodecs.DEFLATE.getAlgorithmName().toUpperCase(), CompressionCodecs.DEFLATE);
    codecMap.put(CompressionCodecs.GZIP.getAlgorithmName().toUpperCase(), CompressionCodecs.GZIP);

    codecs = Collections.unmodifiableMap(codecMap);
}
 
Example #3
Source File: DefaultCompressionCodecResolver.java    From jjwt with Apache License 2.0 5 votes vote down vote up
@Override
public CompressionCodec resolveCompressionCodec(Header header) {
    String cmpAlg = getAlgorithmFromHeader(header);

    final boolean hasCompressionAlgorithm = Strings.hasText(cmpAlg);

    if (!hasCompressionAlgorithm) {
        return null;
    }
    return byName(cmpAlg);
}
 
Example #4
Source File: DefaultCompressionCodecResolver.java    From jjwt with Apache License 2.0 5 votes vote down vote up
private CompressionCodec byName(String name) {
    Assert.hasText(name, "'name' must not be empty");

    CompressionCodec codec = codecs.get(name.toUpperCase());
    if (codec == null) {
        throw new CompressionException(String.format(MISSING_COMPRESSION_MESSAGE, name));
    }

    return codec;
}
 
Example #5
Source File: DefaultJwtBuilder.java    From jjwt with Apache License 2.0 4 votes vote down vote up
@Override
public JwtBuilder compressWith(CompressionCodec compressionCodec) {
    Assert.notNull(compressionCodec, "compressionCodec cannot be null");
    this.compressionCodec = compressionCodec;
    return this;
}