Skip to content

Package: RoleCreator

RoleCreator

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.KapuaNamedEntityCreator;
16: import org.eclipse.kapua.service.authorization.permission.Permission;
17:
18: import javax.xml.bind.annotation.XmlAccessType;
19: import javax.xml.bind.annotation.XmlAccessorType;
20: import javax.xml.bind.annotation.XmlElement;
21: import javax.xml.bind.annotation.XmlElementWrapper;
22: import javax.xml.bind.annotation.XmlRootElement;
23: import javax.xml.bind.annotation.XmlType;
24: import java.security.Permissions;
25: import java.util.Set;
26:
27: /**
28: * {@link RoleCreator} definition.
29: * <p>
30: * It is used to create a new {@link Role} with {@link Permission}s associated
31: *
32: * @since 1.0.0
33: */
34: @XmlRootElement(name = "roleCreator")
35: @XmlAccessorType(XmlAccessType.PROPERTY)
36: @XmlType(factoryClass = RoleXmlRegistry.class, factoryMethod = "newRoleCreator")
37: public interface RoleCreator extends KapuaNamedEntityCreator<Role> {
38:
39: /**
40: * Sets the set of {@link Permissions} to assign to the {@link Role} created entity.
41: * It up to the implementation class to make a clone of the set or use the given set.
42: *
43: * @param permissions The set of {@link Permissions}.
44: * @since 1.0.0
45: */
46: void setPermissions(Set<Permission> permissions);
47:
48: /**
49: * Gets the set of {@link Permission} added to this {@link Role}.
50: * The implementation must return the reference of the set and not make a clone.
51: *
52: * @param <P> The {@link Permission} class implementation.
53: * @return The set of {@link Permission}.
54: * @since 1.0.0
55: */
56: @XmlElementWrapper(name = "permissions")
57: @XmlElement(name = "permission")
58: <P extends Permission> Set<P> getPermissions();
59: }