11/*******************************************************************************
2- * Copyright (c) 2024 Eurotech and/or its affiliates and others
3- *
2+ * Copyright (c) 2024, 2026 Eurotech and/or its affiliates and others
3+ *
44 * This program and the accompanying materials are made
55 * available under the terms of the Eclipse Public License 2.0
66 * which is available at https://www.eclipse.org/legal/epl-2.0/
7- *
7+ *
88 * SPDX-License-Identifier: EPL-2.0
9- *
9+ *
1010 * Contributors:
1111 * Eurotech
1212 ******************************************************************************/
13+ // Content with portions generated by generative AI platform
14+
1315package org .eclipse .kura .identity ;
1416
17+ import java .time .Duration ;
1518import java .util .List ;
1619import java .util .Optional ;
1720import java .util .Set ;
@@ -31,76 +34,101 @@ public interface IdentityService {
3134 /**
3235 * Creates a new identity with the given name.
3336 *
34- * @param identityName the name of the identity to be created.
37+ * @param identityName
38+ * the name of the identity to be created.
3539 * @return {@code true} if the identity with the given name has been created as
3640 * part of the method call or {@code false} if the identity already
37- * exist.
38- * @throws KuraException if a failure occurs in creating the identity.
41+ * exists.
42+ * @throws KuraException
43+ * if a failure occurs in creating the identity.
3944 */
4045 public boolean createIdentity (final String identityName ) throws KuraException ;
4146
4247 /**
43- * Deletes the identity with the given name .
48+ * Creates a new identity using the provided configuration .
4449 *
45- * @param identityName the name of the identity to be deleted.
50+ * @param identityConfiguration
51+ * the identity configuration including identity
52+ * name and optional configuration components.
53+ * @return {@code true} if the identity with the given name has been created as
54+ * part of the method call or {@code false} if the identity already
55+ * exists.
56+ * @throws KuraException
57+ * if a failure occurs in creating the identity.
58+ * @since 2.8.0
59+ */
60+ public boolean createIdentity (final IdentityConfiguration identityConfiguration ) throws KuraException ;
61+
62+ /**
63+ * Deletes the identity with the given name, including temporary identities.
64+ *
65+ * @param identityName
66+ * the name of the identity to be deleted.
4667 * @return {@code true} if the identity with the given name has been deleted as
4768 * part of the method call or {@code false} if the identity does not
4869 * exist.
49- * @throws KuraException if a failure occurs in deleting the identity.
70+ * @throws KuraException
71+ * if a failure occurs in deleting the identity.
5072 */
5173 public boolean deleteIdentity (final String identityName ) throws KuraException ;
5274
5375 /**
5476 * Returns the configuration of all existing identities.
5577 *
56- * @param componentsToReturn the set of {@link IdentityConfigurationComponent}
57- * types to be returned. If the set is empty a
58- * {@link IdentityConfiguration} will be returned for
59- * each defined identity with an empty component list.
60- * This can be used to get the name for all defined
61- * identities.
78+ * @param componentsToReturn
79+ * the set of {@link IdentityConfigurationComponent}
80+ * types to be returned. If the set is empty a
81+ * {@link IdentityConfiguration} will be returned for
82+ * each defined identity with an empty component list.
83+ * This can be used to get the name for all defined
84+ * identities.
6285 *
6386 * @return the list of {@link IdentityConfiguration}s. An empty list will be
6487 * returned if no identities are defined.
65- * @throws KuraException if a failure occurs in retrieving identity
66- * configurations.
88+ * @throws KuraException
89+ * if a failure occurs in retrieving identity
90+ * configurations.
6791 */
6892 public List <IdentityConfiguration > getIdentitiesConfiguration (
69- Set <Class <? extends IdentityConfigurationComponent >> componentsToReturn )
70- throws KuraException ;
93+ Set <Class <? extends IdentityConfigurationComponent >> componentsToReturn ) throws KuraException ;
7194
7295 /**
7396 * Returns the configuration of the identity with the given name.
7497 *
75- * @param identityName the identity name.
76- * @param componentsToReturn the set of {@link IdentityConfigurationComponent}
77- * types to be returned.
98+ * @param identityName
99+ * the identity name.
100+ * @param componentsToReturn
101+ * the set of {@link IdentityConfigurationComponent}
102+ * types to be returned.
78103 * @return the configuration of the requested identity or an empty optional if
79104 * the identity does not exist.
80- * @throws KuraException if a failure occurs in retrieving identity
81- * configuration.
105+ * @throws KuraException
106+ * if a failure occurs in retrieving identity
107+ * configuration.
82108 */
83109 public Optional <IdentityConfiguration > getIdentityConfiguration (final String identityName ,
84- Set <Class <? extends IdentityConfigurationComponent >> componentsToReturn )
85- throws KuraException ;
110+ Set <Class <? extends IdentityConfigurationComponent >> componentsToReturn ) throws KuraException ;
86111
87112 /**
88113 * Returns the default configuration for the identity with the given name, this
89114 * method should succeed even if the identity does not exist. The result should
90115 * be the same configuration returned by the
91- * {@link IdentityService#getIdentityConfiguration(String, List )}
116+ * {@link IdentityService#getIdentityConfiguration(String, Set )}
92117 * method for an identity that has just been created with the
93118 * {@link IdentityService#createIdentity(String)} method.
94119 *
95120 * This method can be useful for example to allow a user interface to show the
96121 * initial identity configuration to the user before creating it.
97122 *
98- * @param identityName the identity name.
99- * @param componentsToReturn the set of {@link IdentityConfigurationComponent}
100- * types to be returned.
123+ * @param identityName
124+ * the identity name.
125+ * @param componentsToReturn
126+ * the set of {@link IdentityConfigurationComponent}
127+ * types to be returned.
101128 * @return the default configuration for the requested identity
102- * @throws KuraException if a failure occurs in retrieving identity
103- * configuration.
129+ * @throws KuraException
130+ * if a failure occurs in retrieving identity
131+ * configuration.
104132 */
105133 public IdentityConfiguration getIdentityDefaultConfiguration (final String identityName ,
106134 Set <Class <? extends IdentityConfigurationComponent >> componentsToReturn ) throws KuraException ;
@@ -109,48 +137,54 @@ public IdentityConfiguration getIdentityDefaultConfiguration(final String identi
109137 * Validates the provided identity configuration without performing any
110138 * change to the system.
111139 *
112- * @param identityConfiguration the identity configuration that should be
113- * validated.
114- * @throws KuraException if the provided identity configuration is not
115- * valid.
140+ * @param identityConfiguration
141+ * the identity configuration that should be
142+ * validated.
143+ * @throws KuraException
144+ * if the provided identity configuration is not
145+ * valid.
116146 */
117- public void validateIdentityConfiguration (final IdentityConfiguration identityConfiguration )
118- throws KuraException ;
147+ public void validateIdentityConfiguration (final IdentityConfiguration identityConfiguration ) throws KuraException ;
119148
120149 /**
121150 * Updates the configuration of the given identity for the provided
122151 * {@link IdentityConfigurationComponent} types.
123152 * The configuration of the identities or identity
124153 * components that have not been provided will not be modified.
125154 *
126- * @param identityConfiguration the identity configuration that should be
127- * updated.
128- * @throws KuraException if a failure occurs updating identity
129- * configuration.
155+ * @param identityConfiguration
156+ * the identity configuration that should be
157+ * updated.
158+ * @throws KuraException
159+ * if a failure occurs updating identity
160+ * configuration.
130161 */
131- public void updateIdentityConfiguration (final IdentityConfiguration identityConfiguration )
132- throws KuraException ;
162+ public void updateIdentityConfiguration (final IdentityConfiguration identityConfiguration ) throws KuraException ;
133163
134164 /**
135165 * Defines a new permission.
136166 *
137- * @param permission the permission to be created.
167+ * @param permission
168+ * the permission to be created.
138169 * @return {@code true} if the permission has been created as
139170 * part of the method call or {@code false} if the permission already
140171 * exist.
141- * @throws KuraException if a failure occurs creating the permission.
172+ * @throws KuraException
173+ * if a failure occurs creating the permission.
142174 */
143175 public boolean createPermission (final Permission permission ) throws KuraException ;
144176
145177 /**
146178 * Removes an existing permission. The permission will also be removed from all
147179 * identities assigned to it.
148180 *
149- * @param permission the permission to be deleted.
181+ * @param permission
182+ * the permission to be deleted.
150183 * @return {@code true} if the permission has been deleted as
151184 * part of the method call or {@code false} if the permission does not
152185 * exist.
153- * @throws KuraException if a failure occurs deleting the permission.
186+ * @throws KuraException
187+ * if a failure occurs deleting the permission.
154188 */
155189 public boolean deletePermission (final Permission permission ) throws KuraException ;
156190
@@ -160,17 +194,20 @@ public void updateIdentityConfiguration(final IdentityConfiguration identityConf
160194 *
161195 * @return the set of permissions that are currently defined within the
162196 * framework.
163- * @throws KuraException if a failure occurs retrieving the permission set.
197+ * @throws KuraException
198+ * if a failure occurs retrieving the permission set.
164199 */
165200 public Set <Permission > getPermissions () throws KuraException ;
166201
167202 /**
168203 * Computes a {@link PasswordHash} for the given plaintext password. The
169204 * password array will be overwritten at the end of the operation.
170205 *
171- * @param password the plaintext password.
206+ * @param password
207+ * the plaintext password.
172208 * @return the computed password hash.
173- * @throws KuraException if a failure occurs computing the password hash
209+ * @throws KuraException
210+ * if a failure occurs computing the password hash
174211 */
175212 public PasswordHash computePasswordHash (final char [] password ) throws KuraException ;
176213
@@ -180,22 +217,65 @@ public void updateIdentityConfiguration(final IdentityConfiguration identityConf
180217 *
181218 * @param identityName
182219 * @param password
183- * @throws KuraException if the passwords do not match of if a failure occurs
184- * while
185- * performing the check.
220+ * @throws KuraException
221+ * if the passwords do not match of if a failure occurs
222+ * while
223+ * performing the check.
186224 */
187225 public void checkPassword (final String identityName , final char [] password ) throws KuraException ;
188226
189227 /**
190228 * Checks if the specified permission is currently assigned to the given
191229 * identity.
192- *
230+ *
193231 * @param identityName
194232 * @param permission
195- * @throws KuraException if the provided permissio is not currently assigned to
196- * the given identity or if occurs while performing the
197- * check.
198- *
233+ * @throws KuraException
234+ * if the provided permission is not currently assigned to
235+ * the given identity or if occurs while performing the
236+ * check.
237+ *
199238 */
200239 public void checkPermission (final String identityName , final Permission permission ) throws KuraException ;
240+
241+ /**
242+ * Creates a temporary identity that is not persisted and has automatic
243+ * expiration. Temporary identities behave like regular identities but are
244+ * stored in-memory only and are automatically removed after the specified
245+ * lifetime period.
246+ *
247+ * @param identityName
248+ * the name of the temporary identity to create.
249+ * @param lifetime
250+ * the duration before automatic expiration. The identity
251+ * will be automatically removed after this period.
252+ * @throws KuraException
253+ * if a failure occurs in creating the temporary identity
254+ * or if an identity with the given name already exists
255+ * (either regular or temporary).
256+ * @since 2.8.0
257+ */
258+ public void createTemporaryIdentity (final String identityName , final Duration lifetime ) throws KuraException ;
259+
260+
261+ /**
262+ * Creates a temporary identity that is not persisted and has automatic
263+ * expiration. Temporary identities behave like regular identities but are
264+ * stored in-memory only and are automatically removed after the specified
265+ * lifetime period.
266+ *
267+ * @param identityConfiguration
268+ * the identity configuration including identity
269+ * name and optional configuration components.
270+ * @param lifetime
271+ * the duration before automatic expiration. The identity
272+ * will be automatically removed after this period.
273+ * @throws KuraException
274+ * if a failure occurs in creating the temporary identity,
275+ * if an identity with the given name already exists
276+ * (either regular or temporary) or if the provided configuration
277+ * is not valid.
278+ * @since 2.8.0
279+ */
280+ public void createTemporaryIdentity (final IdentityConfiguration identityConfiguration , final Duration lifetime ) throws KuraException ;
201281}
0 commit comments