
com.bcgdv.jwt.models.Secret Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of token-generation Show documentation
Show all versions of token-generation Show documentation
JWT token generation with encrypted payloads and CLI
/*
* Secret
*/
package com.bcgdv.jwt.models;
import com.google.common.base.MoreObjects;
import java.util.Map;
import static com.bcgdv.jwt.Params.CONTEXT;
/**
* Base class for generic encapsulated JWT secrets
*/
public abstract class Secret {
/**
* Has a token type
*/
protected Token.Type tokenType;
/**
* Has a map of assertions, as Strings for JSON safety
*/
protected Map assertions;
/**
* Don't use this
*/
protected Secret() {
//don't call me directly
}
/**
* Pass assertions into Secret.
* @param assertions a map of assertions
*/
public Secret(Map assertions) {
if (!assertions.containsKey(CONTEXT.toString())) {
throw new IllegalArgumentException("secret must provide validation context");
}
this.assertions = assertions;
}
/**
* Get the assertions
* @return as Map
*/
public Map getAssertions() {
return assertions;
}
/**
* Get the token's context. Used for callbacks.
* @return as String
*/
public String getContext() {
return assertions.get(CONTEXT.toString());
}
/**
* Get the token type
* @return as TokenType enum
*/
public Token.Type getTokenType() {
return this.tokenType;
}
/**
* Print me with type and assertions
* @return as String
*/
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("tokenType", tokenType)
.add("assertions", getAssertions())
.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy