All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.cidaas.jwt.impl.BasicHeader Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package de.cidaas.jwt.impl;

import de.cidaas.jwt.interfaces.Claim;
import de.cidaas.jwt.interfaces.Header;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectReader;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import static de.cidaas.jwt.impl.JsonNodeClaim.extractClaim;

/**
 * The BasicHeader class implements the Header interface.
 */
class BasicHeader implements Header {
    private final String algorithm;
    private final String type;
    private final String contentType;
    private final String keyId;
    private final Map tree;
    private final ObjectReader objectReader;
    
    BasicHeader(String algorithm, String type, String contentType, String keyId, Map tree, ObjectReader objectReader) {
        this.algorithm = algorithm;
        this.type = type;
        this.contentType = contentType;
        this.keyId = keyId;
        this.tree = Collections.unmodifiableMap(tree == null ? new HashMap() : tree);
        this.objectReader = objectReader;
    }

    Map getTree() {
        return tree;
    }

    @Override
    public String getAlgorithm() {
        return algorithm;
    }

    @Override
    public String getType() {
        return type;
    }

    @Override
    public String getContentType() {
        return contentType;
    }

    @Override
    public String getKeyId() {
        return keyId;
    }

    @Override
    public Claim getHeaderClaim(String name) {
        return extractClaim(name, tree, objectReader);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy