Skip to content

Package: MfaOptionDAO

MfaOptionDAO

nameinstructionbranchcomplexitylinemethod
MfaOptionDAO()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
count(EntityManager, KapuaQuery)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
create(EntityManager, MfaOptionCreator)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
delete(EntityManager, KapuaId, KapuaId)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
find(EntityManager, KapuaId, KapuaId)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
query(EntityManager, KapuaQuery)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
update(EntityManager, MfaOption)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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.credential.mfa.shiro;
14:
15: import org.eclipse.kapua.KapuaEntityNotFoundException;
16: import org.eclipse.kapua.KapuaException;
17: import org.eclipse.kapua.commons.jpa.EntityManager;
18: import org.eclipse.kapua.commons.service.internal.ServiceDAO;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.model.query.KapuaQuery;
21: import org.eclipse.kapua.service.authentication.credential.mfa.MfaOption;
22: import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionCreator;
23: import org.eclipse.kapua.service.authentication.credential.mfa.MfaOptionListResult;
24:
25: /**
26: * {@link MfaOption} {@link ServiceDAO}
27: */
28: public class MfaOptionDAO extends ServiceDAO {
29:
30: /**
31: * Creates and return new {@link MfaOption}
32: *
33: * @param em
34: * @param mfaOptionCreator
35: * @return
36: * @throws KapuaException
37: */
38: public static MfaOption create(EntityManager em, MfaOptionCreator mfaOptionCreator) throws KapuaException {
39:
40: //
41: // Create MfaOption
42: MfaOptionImpl mfaOptionImpl = new MfaOptionImpl(mfaOptionCreator.getScopeId());
43: mfaOptionImpl.setUserId(mfaOptionCreator.getUserId());
44: mfaOptionImpl.setMfaSecretKey(mfaOptionCreator.getMfaSecretKey());
45:
46: //
47: // Do create
48: return ServiceDAO.create(em, mfaOptionImpl);
49: }
50:
51: /**
52: * Update the provided {@link MfaOption}
53: *
54: * @param em
55: * @param mfaOption
56: * @return
57: * @throws KapuaException
58: */
59: public static MfaOption update(EntityManager em, MfaOption mfaOption)
60: throws KapuaException {
61: //
62: // Update
63: MfaOptionImpl mfaOptionImpl = (MfaOptionImpl) mfaOption;
64:
65: return ServiceDAO.update(em, MfaOptionImpl.class, mfaOptionImpl);
66: }
67:
68: /**
69: * Find the {@link MfaOption} by its {@link KapuaId}
70: *
71: * @param em
72: * @param scopeId
73: * @param mfaOptionId
74: * @return
75: */
76: public static MfaOption find(EntityManager em, KapuaId scopeId, KapuaId mfaOptionId) {
77: return ServiceDAO.find(em, MfaOptionImpl.class, scopeId, mfaOptionId);
78: }
79:
80: /**
81: * Return the {@link MfaOption} list matching the provided query
82: *
83: * @param em
84: * @param mfaOptionQuery
85: * @return
86: * @throws KapuaException
87: */
88: public static MfaOptionListResult query(EntityManager em, KapuaQuery mfaOptionQuery) throws KapuaException {
89: return ServiceDAO.query(em, MfaOption.class, MfaOptionImpl.class, new MfaOptionListResultImpl(), mfaOptionQuery);
90: }
91:
92: /**
93: * Return the {@link MfaOption} count matching the provided query
94: *
95: * @param em
96: * @param mfaOptionQuery
97: * @return
98: * @throws KapuaException
99: */
100: public static long count(EntityManager em, KapuaQuery mfaOptionQuery) throws KapuaException {
101: return ServiceDAO.count(em, MfaOption.class, MfaOptionImpl.class, mfaOptionQuery);
102: }
103:
104: /**
105: * Delete the {@link MfaOption} by its {@link KapuaId}
106: *
107: * @param em
108: * @param scopeId
109: * @param mfaOptionId
110: * @return deleted entity
111: * @throws KapuaEntityNotFoundException If {@link MfaOption} is now found.
112: */
113: public static MfaOption delete(EntityManager em, KapuaId scopeId, KapuaId mfaOptionId) throws KapuaEntityNotFoundException {
114: return ServiceDAO.delete(em, MfaOptionImpl.class, scopeId, mfaOptionId);
115: }
116: }