001package com.nimbusds.jose;
002
003
004import java.util.Map;
005import java.util.Set;
006
007import net.minidev.json.JSONObject;
008
009import com.nimbusds.jose.util.Base64URL;
010
011
012/**
013 * Read-only view of a {@link Header header}.
014 *
015 * @author Vladimir Dzhuvinov
016 * @version $version$ (2012-12-09)
017 */
018public interface ReadOnlyHeader {
019
020
021        /**
022         * Gets the algorithm ({@code alg}) parameter.
023         *
024         * @return The algorithm parameter.
025         */
026        public Algorithm getAlgorithm();
027
028
029        /**
030         * Gets the type ({@code typ}) parameter.
031         *
032         * @return The type parameter, {@code null} if not specified.
033         */
034        public JOSEObjectType getType();
035
036
037        /**
038         * Gets the content type ({@code cty}) parameter.
039         *
040         * @return The content type parameter, {@code null} if not specified.
041         */
042        public String getContentType();
043
044
045        /**
046         * Gets a custom (non-reserved) parameter.
047         *
048         * @param name The name of the custom parameter. Must not be 
049         *             {@code null}.
050         *
051         * @return The custom parameter, {@code null} if not specified.
052         */
053        public Object getCustomParameter(final String name);
054
055
056        /**
057         * Gets the custom (non-reserved) parameters.
058         *
059         * @return The custom parameters, as a unmodifiable map, empty map if 
060         *         none.
061         */
062        public Map<String,Object> getCustomParameters();
063
064
065        /**
066         * Gets the names of all included parameters (reserved and custom) in 
067         * the header instance.
068         *
069         * @return The included parameters.
070         */
071        public Set<String> getIncludedParameters();
072
073
074        /**
075         * Returns a JSON object representation of the header. All custom
076         * parameters are included if they serialise to a JSON entity and 
077         * their names don't conflict with the reserved ones.
078         *
079         * @return The JSON object representation of the header.
080         */
081        public JSONObject toJSONObject();
082
083
084        /**
085         * Returns a Base64URL representation of the header.
086         *
087         * @return The Base64URL representation of the header.
088         */
089        public Base64URL toBase64URL();
090}