Skip to content

Package: RolePermission

RolePermission

nameinstructionbranchcomplexitylinemethod
getType()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

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.authorization.role;
14:
15: import org.eclipse.kapua.model.KapuaEntity;
16: import org.eclipse.kapua.model.id.KapuaId;
17: import org.eclipse.kapua.model.id.KapuaIdAdapter;
18: import org.eclipse.kapua.service.authorization.permission.Permission;
19:
20: import javax.management.relation.RoleInfo;
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:
28: /**
29: * Role permission entity.<br>
30: * Describes a {@link Permission} associated to the role.<br>
31: * Wrapping of the {@link Permission} into this class is intended to adds auditing
32: * informations like {@link RolePermission#getCreatedBy()} and{@link RolePermission#getCreatedOn()}.<br>
33: * <br>
34: * This is a not editable entity so it can be only removed or created and therefore any change to
35: * {@link RolePermission#getRoleId()} and {@link RolePermission#getPermission()} property is forbidden.
36: *
37: * @since 1.0.0
38: */
39: @XmlRootElement(name = "rolePermission")
40: @XmlAccessorType(XmlAccessType.PROPERTY)
41: @XmlType(propOrder = { "roleId",
42: "permission" }, //
43: factoryClass = RolePermissionXmlRegistry.class, //
44: factoryMethod = "newRolePermission")
45: public interface RolePermission extends KapuaEntity {
46:
47: String TYPE = "rolePermission";
48:
49: @Override
50: default String getType() {
51: return TYPE;
52: }
53:
54: /**
55: * Sets the {@link Role} id of which this {@link RolePermission} belongs.
56: *
57: * @param roleId The {@link RoleInfo} id.
58: * @since 1.0.0
59: */
60: void setRoleId(KapuaId roleId);
61:
62: /**
63: * Gets the {@link Role} id of which this {@link RolePermission} belongs.
64: *
65: * @return The {@link Role} id.
66: * @since 1.0.0
67: */
68: @XmlElement(name = "roleId")
69: @XmlJavaTypeAdapter(KapuaIdAdapter.class)
70: KapuaId getRoleId();
71:
72: /**
73: * Sets the {@link Permission} that this {@link RolePermission} has.<br>
74: * It up to the implementation class to make a clone of the given {@link Permission} or use the given {@link Permission}.
75: *
76: * @param permission The {@link Permission} to set for this {@link RolePermission}.
77: * @since 1.0.0
78: */
79: void setPermission(Permission permission);
80:
81: /**
82: * Gets the {@link Permission} that this {@link RolePermission} has.
83: *
84: * @param <P> The {@link Permission} class implementation.
85: * @return The {@link Permission} that this {@link RolePermission} has.
86: * @since 1.0.0
87: */
88: @XmlElement(name = "permission")
89: <P extends Permission> P getPermission();
90: }