|
Message Security Layer (MSL) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.netflix.msl.tokens.MasterToken
public class MasterToken
The master token provides proof of remote entity identity. A MSL-specific crypto context is used to encrypt the master token data and generate the master token verification data. The remote entity cannot decrypt the master token data or generate the master token verification data.
The master token session keys will be used for MSL message encryption and integrity protection. The use of these session keys implies the MSL message identity as specified in the master token.
Master tokens also contain a sequence number identifying the issue number of the token. This is a monotonically increasing number that is incremented by one each time a master token is renewed.
When in possession of multiple master tokens, the token with the highest sequence number should be considered the newest token. Since the sequence number space is signed 53-bit numbers, if a sequence number is smaller by more than 45-bits (e.g. the new sequence number is <= 128 and the old sequence number is 2^53), it is considered the newest token.
The renewal window indicates the time after which the master token will be renewed if requested by the entity. The expiration is the time after which the master token will be renewed no matter what.
Master tokens also contain a serial number against which all other tokens are bound. Changing the serial number when the master token is renewed invalidates all of those tokens.
The issuer identity identifies the issuer of this master token, which may be useful to services that accept the master token.
While there can be multiple versions of a master token, this class should encapsulate support for all of those versions.
Master tokens are represented as
mastertoken = {
"#mandatory" : [ "tokendata", "signature" ],
"tokendata" : "base64",
"signature" : "base64"
}
where:
tokendata
is the Base64-encoded master token data (mastertokendata)signature
is the Base64-encoded verification data of the master token dataThe token data is represented as
mastertokendata = {
"#mandatory" : [ "renewalwindow", "expiration", "sequencenumber", "serialnumber", "sessiondata" ],
"renewalwindow" : "int64(0,-)",
"expiration" : "int64(0,-)",
"sequencenumber" : "int64(0,2^53^)",
"serialnumber" : "int64(0,2^53^)",
"sessiondata" : "base64"
}
where:
renewalwindow
is when the renewal window opens in seconds since the epochexpiration
is the expiration timestamp in seconds since the epochsequencenumber
is the master token sequence numberserialnumber
is the master token serial numbersessiondata
is the Base64-encoded encrypted session data (sessiondata)The decrypted session data is represented as
sessiondata = {
"#mandatory" : [ "identity", "encryptionkey", "hmackey" ],
"issuerdata" : object,
"identity" : "string",
"encryptionkey" : "base64",
"hmackey" : "base64"
}
where:
issuerdata
is the master token issuer dataidentity
is the identifier of the remote entityencryptionkey
is the Base64-encoded AES-128 encryption session keyhmackey
is the Base64-encoded SHA-256 HMAC session key
Field Summary | |
---|---|
private MslContext |
ctx
MSL context. |
private SecretKey |
encryptionKey
Encryption key. |
private long |
expiration
Master token expiration in seconds since the epoch. |
private SecretKey |
hmacKey
HMAC key. |
private String |
identity
Entity identity. |
private JSONObject |
issuerData
Issuer data. |
private static String |
KEY_ENCRYPTION_KEY
JSON key symmetric encryption key. |
private static String |
KEY_EXPIRATION
JSON key expiration timestamp. |
private static String |
KEY_HMAC_KEY
JSON key symmetric HMAC key. |
private static String |
KEY_IDENTITY
JSON key identity. |
private static String |
KEY_ISSUER_DATA
JSON key issuer data. |
private static String |
KEY_RENEWAL_WINDOW
JSON key renewal window timestamp. |
private static String |
KEY_SEQUENCE_NUMBER
JSON key sequence number. |
private static String |
KEY_SERIAL_NUMBER
JSON key serial number. |
private static String |
KEY_SESSIONDATA
JSON key session data. |
private static String |
KEY_SIGNATURE
JSON key signature. |
private static String |
KEY_TOKENDATA
JSON key token data. |
private static long |
MILLISECONDS_PER_SECOND
Milliseconds per second. |
private long |
renewalWindow
Master token renewal window in seconds since the epoch. |
private long |
sequenceNumber
Sequence number. |
private long |
serialNumber
Serial number. |
private byte[] |
sessiondata
Session data. |
private byte[] |
signature
Master token signature. |
private byte[] |
tokendata
Token data. |
private boolean |
verified
Token is verified. |
Constructor Summary | |
---|---|
MasterToken(MslContext ctx,
Date renewalWindow,
Date expiration,
long sequenceNumber,
long serialNumber,
JSONObject issuerData,
String identity,
SecretKey encryptionKey,
SecretKey hmacKey)
Create a new master token with the specified expiration, identity, serial number, and encryption and HMAC keys. |
|
MasterToken(MslContext ctx,
JSONObject masterTokenJO)
Create a new master token from the provided JSON. |
Method Summary | |
---|---|
boolean |
equals(Object obj)
|
SecretKey |
getEncryptionKey()
|
Date |
getExpiration()
|
SecretKey |
getHmacKey()
|
String |
getIdentity()
Returns the identifier of the authenticated peer. |
JSONObject |
getIssuerData()
Returns the issuer data. |
Date |
getRenewalWindow()
|
long |
getSequenceNumber()
|
long |
getSerialNumber()
|
int |
hashCode()
|
boolean |
isDecrypted()
|
boolean |
isExpired()
|
boolean |
isNewerThan(MasterToken that)
A master token is considered newer if its sequence number is greater than another master token. |
boolean |
isRenewable()
|
boolean |
isVerified()
|
String |
toJSONString()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long MILLISECONDS_PER_SECOND
private static final String KEY_TOKENDATA
private static final String KEY_SIGNATURE
private static final String KEY_RENEWAL_WINDOW
private static final String KEY_EXPIRATION
private static final String KEY_SEQUENCE_NUMBER
private static final String KEY_SERIAL_NUMBER
private static final String KEY_SESSIONDATA
private static final String KEY_ISSUER_DATA
private static final String KEY_IDENTITY
private static final String KEY_ENCRYPTION_KEY
private static final String KEY_HMAC_KEY
private final MslContext ctx
private final byte[] tokendata
private final byte[] signature
private final long renewalWindow
private final long expiration
private final long sequenceNumber
private final long serialNumber
private final byte[] sessiondata
private final JSONObject issuerData
private final String identity
private final SecretKey encryptionKey
private final SecretKey hmacKey
private final boolean verified
Constructor Detail |
---|
public MasterToken(MslContext ctx, Date renewalWindow, Date expiration, long sequenceNumber, long serialNumber, JSONObject issuerData, String identity, SecretKey encryptionKey, SecretKey hmacKey) throws MslEncodingException, MslCryptoException
ctx
- MSL context.renewalWindow
- the renewal window.expiration
- the expiration.sequenceNumber
- the master token sequence number.serialNumber
- the master token serial number.issuerData
- the issuer data. May be null.identity
- the singular identity this master token represents.encryptionKey
- the session encryption key.hmacKey
- the session HMAC key.
MslEncodingException
- if there is an error encoding the JSON
data.
MslCryptoException
- if there is an error encrypting or signing
the token data.public MasterToken(MslContext ctx, JSONObject masterTokenJO) throws MslEncodingException, MslCryptoException, MslException
ctx
- MSL context.masterTokenJO
- master token JSON object.
MslEncodingException
- if there is an error parsing the JSON,
the token data is missing or invalid, the signature is missing
or invalid, or the session data is missing or invalid.
MslCryptoException
- if there is an error verifying the token data
or extracting the session keys.
MslException
- if the expiration timestamp occurs before the
renewal window, or the sequence number is out of range, or the
serial number is out of range.Method Detail |
---|
public boolean isDecrypted()
public boolean isVerified()
public Date getRenewalWindow()
public boolean isRenewable()
public Date getExpiration()
public boolean isExpired()
public long getSequenceNumber()
public long getSerialNumber()
public boolean isNewerThan(MasterToken that)
A master token is considered newer if its sequence number is greater than another master token. If both the sequence numbers are equal, then the master token with the later expiration date is considered newer.
Serial numbers are not taken into consideration when comparing which master token is newer because serial numbers will change when new master tokens are created as opposed to renewed. The caller of this function should already be comparing master tokens that can be used interchangeably (i.e. for the same MSL network).
that
- the master token to compare with.
public JSONObject getIssuerData()
public String getIdentity()
public SecretKey getEncryptionKey()
public SecretKey getHmacKey()
public String toJSONString()
public String toString()
toString
in class Object
public boolean equals(Object obj)
equals
in class Object
obj
- the reference object with which to compare.
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in class Object
|
Message Security Layer (MSL) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |