Skip to content

Package: MfaAuthenticator

MfaAuthenticator

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2020, 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.mfa;
14:
15: import org.eclipse.kapua.KapuaException;
16:
17: import java.util.List;
18:
19: /**
20: * {@link MfaAuthenticator} definition.
21: *
22: * @since 1.3.0
23: */
24: public interface MfaAuthenticator {
25:
26: /**
27: * Whether the {@link MfaAuthenticator} service is enabled or not.
28: *
29: * @return {@code true} if the {@link MfaAuthenticator} is enabled, {@code false} otherwise.
30: * @since 1.3.0
31: */
32: boolean isEnabled();
33:
34: /**
35: * Validates a code generated with the authenticator app.
36: *
37: * @param mfaSecretKey The MFA secret key.
38: * @param verificationCode The verification code
39: * @return {@code true} if the verficationCode is valid, {@code false} otherwise.
40: * @throws KapuaException
41: * @since 1.3.0
42: */
43: boolean authorize(String mfaSecretKey, int verificationCode) throws KapuaException;
44:
45: /**
46: * Validates a scratch code.
47: *
48: * @param hashedScratchCode The hashed scratch code
49: * @param authCode The plaintext authentication code
50: * @return {@code true} if the code match, {@code false} otherwise
51: * @throws KapuaException
52: * @since 1.3.0
53: */
54: boolean authorize(String hashedScratchCode, String authCode) throws KapuaException;
55:
56: /**
57: * Generates the secret key
58: *
59: * @return The secret key in the form of a {@link String}
60: * @throws KapuaException
61: * @since 1.3.0
62: */
63: String generateKey() throws KapuaException;
64:
65: /**
66: * Generates the {@link List} of scratch codes.
67: *
68: * @return the list of scratch codes in the form of Strings
69: * @throws KapuaException
70: * @since 1.3.0
71: */
72: List<String> generateCodes() throws KapuaException;
73: }