Skip to contentPackage: AccessToken
AccessToken
name | instruction | branch | complexity | line | method |
---|
getType() |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.authentication.token;
14:
15: import org.eclipse.kapua.model.KapuaUpdatableEntity;
16: import org.eclipse.kapua.model.id.KapuaId;
17: import org.eclipse.kapua.model.id.KapuaIdAdapter;
18: import org.eclipse.kapua.model.xml.DateXmlAdapter;
19: import org.eclipse.kapua.service.user.User;
20:
21: import javax.xml.bind.annotation.XmlAccessType;
22: import javax.xml.bind.annotation.XmlAccessorType;
23: import javax.xml.bind.annotation.XmlElement;
24: import javax.xml.bind.annotation.XmlRootElement;
25: import javax.xml.bind.annotation.XmlType;
26: import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
27: import java.io.Serializable;
28: import java.util.Date;
29:
30: /**
31: * {@link AccessToken} entity.
32: *
33: * @since 1.0.0
34: */
35: @XmlRootElement
36: @XmlAccessorType(XmlAccessType.PROPERTY)
37: @XmlType(propOrder = { //
38: "tokenId", //
39: "userId", //
40: "expiresOn", //
41: "refreshToken", //
42: "refreshExpiresOn", //
43: "invalidatedOn", //
44: "trustKey" //
45: }, //
46: factoryClass = AccessTokenXmlRegistry.class, //
47: factoryMethod = "newAccessToken")
48: public interface AccessToken extends KapuaUpdatableEntity, Serializable {
49:
50: String TYPE = "accessToken";
51:
52: @Override
53: default String getType() {
54: return TYPE;
55: }
56:
57: /**
58: * Return the token identifier
59: *
60: * @return the token identifier
61: * @since 1.0.0
62: */
63: @XmlElement(name = "tokenId")
64: String getTokenId();
65:
66: /**
67: * Sets the token id
68: *
69: * @param tokenId The token id.
70: * @since 1.0.0
71: */
72: void setTokenId(String tokenId);
73:
74: /**
75: * Return the user identifier
76: *
77: * @return The user identifier.
78: * @since 1.0.0
79: */
80: @XmlElement(name = "userId")
81: @XmlJavaTypeAdapter(KapuaIdAdapter.class)
82: KapuaId getUserId();
83:
84: /**
85: * Sets the {@link User} id of this {@link AccessToken}
86: *
87: * @param userId The {@link User} id to set.
88: * @since 1.0.0
89: */
90: void setUserId(KapuaId userId);
91:
92: /**
93: * Gets the expire date of this token.
94: *
95: * @return The expire date of this token.
96: * @since 1.0.0
97: */
98: @XmlElement(name = "expiresOn")
99: @XmlJavaTypeAdapter(DateXmlAdapter.class)
100: Date getExpiresOn();
101:
102: /**
103: * Sets the expire date of this token.
104: *
105: * @param expiresOn The expire date of this token.
106: * @since 1.0.0
107: */
108: void setExpiresOn(Date expiresOn);
109:
110: /**
111: * Gets the refresh token to obtain a new {@link AccessToken} after expiration.
112: *
113: * @return The refresh token to obtain a new {@link AccessToken} after expiration.
114: * @since 1.0.0
115: */
116: @XmlElement(name = "refreshToken")
117: String getRefreshToken();
118:
119: /**
120: * Sets the refresh token to obtain a new {@link AccessToken} after expiration.
121: *
122: * @param refreshToken The refresh token
123: * @since 1.0.0
124: */
125: void setRefreshToken(String refreshToken);
126:
127: /**
128: * Gets the expiration date of the refresh token.
129: *
130: * @return The expiration date of the refresh token.
131: * @since 1.0.0
132: */
133: @XmlElement(name = "refreshExpiresOn")
134: @XmlJavaTypeAdapter(DateXmlAdapter.class)
135: Date getRefreshExpiresOn();
136:
137: /**
138: * Sets the expire date of this token.
139: *
140: * @param refreshExpiresOn The expiration date of the refresh token.
141: * @since 1.0.0
142: */
143: void setRefreshExpiresOn(Date refreshExpiresOn);
144:
145: /**
146: * Gets the date the token has been invalidated (i.e. the date
147: * the refresh token has been used, or it has been invalidated due
148: * to a logout)
149: *
150: * @return The date the token has been invalidated.
151: * @since 1.0.0
152: */
153: @XmlElement(name = "invalidatedOn")
154: @XmlJavaTypeAdapter(DateXmlAdapter.class)
155: Date getInvalidatedOn();
156:
157: /**
158: * Sets the date the token has been invalidated (i.e. the date
159: * the refresh token has been used, or it has been invalidated due
160: * to a logout)
161: *
162: * @param invalidatedOn The date when the token has been invalidated.
163: * @since 1.0.0
164: */
165: void setInvalidatedOn(Date invalidatedOn);
166:
167: /**
168: * Gets the MFA trust key
169: *
170: * @return the value of the mfa trust key
171: * @since 1.4.0
172: */
173: @XmlElement(name = "trustKey")
174: String getTrustKey();
175:
176: /**
177: * Sets the MFA trust key
178: *
179: * @param trustKey the mfa trust key to be set
180: * @since 1.4.0
181: */
182: void setTrustKey(String trustKey);
183:
184: }