io.phasetwo.keycloak.magic.auth.token.MagicLinkActionToken Maven / Gradle / Ivy
package io.phasetwo.keycloak.magic.auth.token;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.keycloak.authentication.actiontoken.DefaultActionToken;
public class MagicLinkActionToken extends DefaultActionToken {
public static final String TOKEN_TYPE = "ext-magic-link";
private static final String JSON_FIELD_REDIRECT_URI = "rdu";
private static final String JSON_FIELD_SCOPE = "scope";
private static final String JSON_FIELD_NONCE = "nonce";
private static final String JSON_FIELD_STATE = "state";
private static final String JSON_FIELD_REMEMBER_ME = "rme";
@JsonProperty(value = JSON_FIELD_REDIRECT_URI)
private String redirectUri;
@JsonProperty(value = JSON_FIELD_SCOPE)
private String scopes;
@JsonProperty(value = JSON_FIELD_NONCE)
private String nonce;
@JsonProperty(value = JSON_FIELD_STATE)
private String state;
@JsonProperty(value = JSON_FIELD_REMEMBER_ME)
private Boolean rememberMe = false;
public MagicLinkActionToken(
String userId, int absoluteExpirationInSecs, String clientId, String redirectUri) {
super(userId, TOKEN_TYPE, absoluteExpirationInSecs, null);
this.redirectUri = redirectUri;
this.issuedFor = clientId;
}
public MagicLinkActionToken(
String userId,
int absoluteExpirationInSecs,
String clientId,
String redirectUri,
String scope,
String nonce,
String state) {
super(userId, TOKEN_TYPE, absoluteExpirationInSecs, null);
this.redirectUri = redirectUri;
this.issuedFor = clientId;
this.scopes = scope;
this.nonce = nonce;
this.state = state;
}
public MagicLinkActionToken(
String userId,
int absoluteExpirationInSecs,
String clientId,
String redirectUri,
String scope,
String nonce,
String state,
Boolean rememberMe) {
super(userId, TOKEN_TYPE, absoluteExpirationInSecs, null);
this.redirectUri = redirectUri;
this.issuedFor = clientId;
this.scopes = scope;
this.nonce = nonce;
this.state = state;
this.rememberMe = rememberMe;
}
private MagicLinkActionToken() {
// Note that the class must have a private constructor without any arguments. This is necessary
// to deserialize the token class from JWT.
}
public String getRedirectUri() {
return redirectUri;
}
public void setRedirectUri(String redirectUri) {
this.redirectUri = redirectUri;
}
public String getScope() {
return this.scopes;
}
public void setScope(String value) {
this.scopes = value;
}
public String getNonce() {
return this.nonce;
}
public void setNonce(String value) {
this.nonce = value;
}
public String getState() {
return this.state;
}
public void setState(String value) {
this.state = value;
}
public Boolean getRememberMe() {
return this.rememberMe;
}
public void setRememberMe(Boolean value) {
this.rememberMe = value;
}
}