package com.atlassian.bitbucket.internal.mirroring.mirror.auth;

import javax.annotation.Nonnull;
import java.util.Date;

public class OAuthAccessToken {
    private final String key;
    private final long expiryTimestamp;

    public OAuthAccessToken(String key, Date expiry) {
        this.key = key;
        this.expiryTimestamp = expiry.getTime();
    }

    @Nonnull
    public long getExpiryTimestamp() {
        return expiryTimestamp;
    }

    @Nonnull
    public String getValue() {
        return key;
    }

    public boolean isExpired() {
        return System.currentTimeMillis() >= expiryTimestamp;
    }
}
