/*
|
http-oauth - OAuth Extensions to jdk.httpserver
|
Copyright (C) 2021 Ulrich Hilger
|
|
This program is free software: you can redistribute it and/or modify
|
it under the terms of the GNU Affero General Public License as
|
published by the Free Software Foundation, either version 3 of the
|
License, or (at your option) any later version.
|
|
This program is distributed in the hope that it will be useful,
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
GNU Affero General Public License for more details.
|
|
You should have received a copy of the GNU Affero General Public License
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
*/
|
package de.uhilger.httpserver.oauth;
|
|
import com.google.gson.Gson;
|
|
/**
|
* Die Klasse LoginResponse modelliert die Antwort auf eine HTTP-Anfrage
|
* gemaess Bearer Authentication nach RFC 6750
|
*
|
* @author Ulrich Hilger
|
* @version 1, 08.6.2021
|
*/
|
public class LoginResponse {
|
/*
|
HTTP/1.1 200 OK
|
Content-Type: application/json;charset=UTF-8
|
Cache-Control: no-store
|
Pragma: no-cache
|
|
{
|
"access_token":"mF_9.B5f-4.1JqM",
|
"token_type":"Bearer",
|
"expires_in":3600,
|
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
|
}
|
*/
|
|
private String access_token;
|
private final String token_type = BearerAuthenticator.BEARER;
|
private long expires_in;
|
private String refresh_token;
|
|
/**
|
* Den Token ermitteln
|
* @return der Token
|
*/
|
public String getToken() {
|
return access_token;
|
}
|
|
/**
|
* Den Token eintragen
|
* @param token der Token
|
*/
|
public void setToken(String token) {
|
this.access_token = token;
|
}
|
|
/**
|
* Den Refresh-Token ermitteln
|
* @return der Refreh-Token
|
*/
|
public String getRefreshToken() {
|
return refresh_token;
|
}
|
|
/**
|
* Den Refresh-Token eintragen
|
* @param refreshToken der Refresh Token
|
*/
|
public void setRefreshToken(String refreshToken) {
|
this.refresh_token = refreshToken;
|
}
|
|
/**
|
* Den Token-Typ bestimmen
|
* @return der Token-Typ
|
*/
|
public String getTokenType() {
|
return token_type;
|
}
|
|
/**
|
* Die Anzahl der Sekunden ermitteln, nach denen der
|
* Token ungueltig wird
|
* @return die Anzahl Sekunden bis der Token ungueltg wird
|
*/
|
public long getExpiresIn() {
|
return expires_in;
|
}
|
|
/**
|
* Die Anzahl der Sekunden setzen, nach denen der
|
* Token ungueltig wird
|
*
|
* @param seconds die Anzahl Sekunden bis der Token ungueltg wird
|
*/
|
public void setExpiresIn(long seconds) {
|
this.expires_in = seconds;
|
}
|
|
/**
|
* Dieses Objekt nach JSON uebersetzen
|
* @return das Objekt in JSON
|
*/
|
public String toJson() {
|
Gson gson = new Gson();
|
return gson.toJson(this);
|
}
|
}
|