commit | author | age
|
177043
|
1 |
/* |
U |
2 |
neon-auth - Authentication Extensions to Neon |
|
3 |
Copyright (C) 2024 Ulrich Hilger |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU Affero General Public License as |
|
7 |
published by the Free Software Foundation, either version 3 of the |
|
8 |
License, or (at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU Affero General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU Affero General Public License |
|
16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
package de.uhilger.neon.auth; |
|
19 |
|
|
20 |
import com.google.gson.Gson; |
|
21 |
|
|
22 |
/** |
|
23 |
* Die Klasse LoginResponse modelliert die Antwort auf eine HTTP-Anfrage |
|
24 |
* gemaess Bearer Authentication nach RFC 6750 |
|
25 |
* |
|
26 |
* @author Ulrich Hilger |
|
27 |
* @version 1, 08.6.2021 |
|
28 |
*/ |
|
29 |
public class LoginResponse { |
|
30 |
/* |
|
31 |
HTTP/1.1 200 OK |
|
32 |
Content-Type: application/json;charset=UTF-8 |
|
33 |
Cache-Control: no-store |
|
34 |
Pragma: no-cache |
|
35 |
|
|
36 |
{ |
|
37 |
"access_token":"mF_9.B5f-4.1JqM", |
|
38 |
"token_type":"Bearer", |
|
39 |
"expires_in":3600, |
|
40 |
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA" |
|
41 |
} |
|
42 |
*/ |
|
43 |
|
|
44 |
private String access_token; |
|
45 |
private final String token_type = BearerAuthenticator.BEARER; |
|
46 |
private long expires_in; |
|
47 |
private String refresh_token; |
|
48 |
|
|
49 |
/** |
|
50 |
* Den Token ermitteln |
|
51 |
* @return der Token |
|
52 |
*/ |
|
53 |
public String getToken() { |
|
54 |
return access_token; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Den Token eintragen |
|
59 |
* @param token der Token |
|
60 |
*/ |
|
61 |
public void setToken(String token) { |
|
62 |
this.access_token = token; |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* Den Refresh-Token ermitteln |
|
67 |
* @return der Refreh-Token |
|
68 |
*/ |
|
69 |
public String getRefreshToken() { |
|
70 |
return refresh_token; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Den Refresh-Token eintragen |
|
75 |
* @param refreshToken der Refresh Token |
|
76 |
*/ |
|
77 |
public void setRefreshToken(String refreshToken) { |
|
78 |
this.refresh_token = refreshToken; |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* Den Token-Typ bestimmen |
|
83 |
* @return der Token-Typ |
|
84 |
*/ |
|
85 |
public String getTokenType() { |
|
86 |
return token_type; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Die Anzahl der Sekunden ermitteln, nach denen der |
|
91 |
* Token ungueltig wird |
|
92 |
* @return die Anzahl Sekunden bis der Token ungueltg wird |
|
93 |
*/ |
|
94 |
public long getExpiresIn() { |
|
95 |
return expires_in; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Die Anzahl der Sekunden setzen, nach denen der |
|
100 |
* Token ungueltig wird |
|
101 |
* |
|
102 |
* @param seconds die Anzahl Sekunden bis der Token ungueltg wird |
|
103 |
*/ |
|
104 |
public void setExpiresIn(long seconds) { |
|
105 |
this.expires_in = seconds; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Dieses Objekt nach JSON uebersetzen |
|
110 |
* @return das Objekt in JSON |
|
111 |
*/ |
|
112 |
public String toJson() { |
|
113 |
Gson gson = new Gson(); |
|
114 |
return gson.toJson(this); |
|
115 |
} |
|
116 |
} |