All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vrap.rmf.base.client.AuthenticationToken Maven / Gradle / Ivy

There is a newer version: 17.15.1
Show newest version
package io.vrap.rmf.base.client;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.ZonedDateTime;
import java.util.Optional;

public class AuthenticationToken {

    @JsonProperty("access_token")
    private String accessToken;

    @JsonProperty("token_type")
    private String tokenType;

    @JsonProperty("expires_in")
    private Long expiresIn;

    @JsonProperty("scope")
    private String scope;

    @JsonProperty("refresh_token")
    private String refresherToken;

    @JsonIgnore
    private ZonedDateTime expiresInZonedDateTime;

    public AuthenticationToken() {
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getTokenType() {
        return tokenType;
    }

    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }

    public Long getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(Long expiresIn) {
        this.expiresInZonedDateTime = Optional.ofNullable(expiresIn).map(seconds -> ZonedDateTime.now().plusSeconds(seconds).minusMinutes(5)).orElse(null);
        this.expiresIn = expiresIn;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getRefresherToken() {
        return refresherToken;
    }

    public void setRefresherToken(String refresherToken) {
        this.refresherToken = refresherToken;
    }

    public ZonedDateTime getExpiresInZonedDateTime() {
        return expiresInZonedDateTime;
    }

    public boolean isExpired() {
        return expiresInZonedDateTime != null && expiresInZonedDateTime.isBefore(ZonedDateTime.now());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy