001 package com.nimbusds.jwt; 002 003 004 import java.util.Date; 005 import java.util.List; 006 import java.util.Map; 007 008 import net.minidev.json.JSONObject; 009 010 011 /** 012 * Read-only view of a {@link JWTClaimsSet}. 013 * 014 * @author Vladimir Dzhuvinov 015 * @author Justin Richer 016 * @version $version$ (2013-02-21) 017 */ 018 public interface ReadOnlyJWTClaimsSet { 019 020 021 /** 022 * Gets the issuer ({@code iss}) claim. 023 * 024 * @return The issuer claim, {@code null} if not specified. 025 */ 026 public String getIssuer(); 027 028 029 /** 030 * Gets the subject ({@code sub}) claim. 031 * 032 * @return The subject claim, {@code null} if not specified. 033 */ 034 public String getSubject(); 035 036 037 /** 038 * Gets the audience ({@code aud}) clam. 039 * 040 * @return The audience claim, {@code null} if not specified. 041 */ 042 public List<String> getAudience(); 043 044 045 /** 046 * Gets the expiration time ({@code exp}) claim. 047 * 048 * @return The expiration time, {@code null} if not specified. 049 */ 050 public Date getExpirationTime(); 051 052 053 /** 054 * Gets the not-before ({@code nbf}) claim. 055 * 056 * @return The not-before claim, {@code null} if not specified. 057 */ 058 public Date getNotBeforeTime(); 059 060 061 /** 062 * Gets the issued-at ({@code iat}) claim. 063 * 064 * @return The issued-at claim, {@code null} if not specified. 065 */ 066 public Date getIssueTime(); 067 068 069 /** 070 * Gets the JWT ID ({@code jti}) claim. 071 * 072 * @return The JWT ID claim, {@code null} if not specified. 073 */ 074 public String getJWTID(); 075 076 077 /** 078 * Gets the type ({@code typ}) claim. 079 * 080 * @return The type claim, {@code null} if not specified. 081 */ 082 public String getType(); 083 084 085 /** 086 * Gets a custom (non-reserved) claim. 087 * 088 * @param name The name of the custom claim. Must not be {@code null}. 089 * 090 * @return The value of the custom claim, {@code null} if not specified. 091 */ 092 public Object getCustomClaim(final String name); 093 094 095 /** 096 * Gets the custom (non-reserved) claims. 097 * 098 * @return The custom claims, as a unmodifiable map, empty map if none. 099 */ 100 public Map<String,Object> getCustomClaims(); 101 102 /** 103 * Gets a single claim by name, whether reserved or custom. 104 * 105 * @param name The name of the claim to get. Must not be {@code null}. 106 * 107 * @return The value of the claim, {@code null} if not specified. 108 */ 109 public Object getClaim(final String name); 110 111 112 /** 113 * Gets all claims, both reserved and custom, as a single map. 114 * 115 * <p>Note that the reserved claims Expiration-Time ({@code exp}), 116 * Not-Before-Time ({@code nbf}) and Issued-At ({@code iat}) will be 117 * returned as {@code java.util.Date} instances. 118 * 119 * @return All claims, as an unmodifiable map, empty map if none. 120 */ 121 public Map<String, Object> getAllClaims(); 122 123 124 /** 125 * Returns the JSON object representation of the claims set. 126 * 127 * @return The JSON object representation. 128 */ 129 public JSONObject toJSONObject(); 130 }