Skip to content

Commit

Permalink
feat(rest.security.provider): Added REST Api for Security Service (#4843
Browse files Browse the repository at this point in the history
)

* Added org.eclipse.kura.rest.security.provider

* Added tests

* Added new bundle to distribution

* added required bundle for testing.

* updated test.

* Fixed test http methods

* Fixed REST_APP_ID.

* Set SecurityService to optional

* Added thenResponseBodyIsEmpty

* added enabled true expected json message

* Fixed SecurityService name

* Added immediate

* Fixed SecurityRestService fqn

* fixed test.

* fixed EXPECTED_DEBUG_ENABLE_TRUE_RESPONSE

* added reset mock to givenSecurityService

* fixed json string

* removed unnecessary resources folder

* removed unnecessary package import
  • Loading branch information
salvatore-coppola authored and pierantoniomerlino committed Sep 26, 2023
1 parent c101efc commit 25ca1a2
Show file tree
Hide file tree
Showing 18 changed files with 1,100 additions and 2 deletions.
1 change: 1 addition & 0 deletions kura/distrib/config/kura.build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ org.eclipse.kura.rest.configuration.provider.version=1.3.0-SNAPSHOT
org.eclipse.kura.rest.inventory.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.command.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.position.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.security.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.rest.system.provider.version=1.0.0-SNAPSHOT
org.eclipse.kura.request.handler.jaxrs.version=1.3.0-SNAPSHOT
org.eclipse.kura.rest.wire.provider.version=1.3.0-SNAPSHOT
Expand Down
11 changes: 9 additions & 2 deletions kura/distrib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@
<artifactId>org.eclipse.kura.rest.position.provider</artifactId>
<version>${org.eclipse.kura.rest.position.provider.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.rest.security.provider</artifactId>
<version>${org.eclipse.kura.rest.security.provider.version}</version>
</artifactItem>
<artifactItem>
<groupId>org.eclipse.kura</groupId>
<artifactId>org.eclipse.kura.rest.system.provider</artifactId>
Expand Down Expand Up @@ -809,9 +814,10 @@
<move file="target/plugins/org.eclipse.kura.log.filesystem.provider.jar" tofile="target/plugins/org.eclipse.kura.log.filesystem.provider_${org.eclipse.kura.log.filesystem.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.configuration.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.configuration.provider_${org.eclipse.kura.rest.configuration.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.inventory.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.inventory.provider_${org.eclipse.kura.rest.inventory.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.command.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.command.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.position.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.system.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.security.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.system.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.request.handler.jaxrs.jar" tofile="target/plugins/org.eclipse.kura.request.handler.jaxrs_${org.eclipse.kura.request.handler.jaxrs.version}.jar" />
<move file="target/plugins/org.eclipse.kura.rest.wire.provider.jar" tofile="target/plugins/org.eclipse.kura.rest.wire.provider_${org.eclipse.kura.rest.wire.provider.version}.jar" />
<move file="target/plugins/org.eclipse.kura.container.orchestration.provider.jar" tofile="target/plugins/org.eclipse.kura.container.orchestration.provider_${org.eclipse.kura.container.orchestration.provider.version}.jar" />
Expand Down Expand Up @@ -2524,6 +2530,7 @@
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.inventory.provider_${org.eclipse.kura.rest.inventory.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<copy file="${project.build.directory}/plugins/org.eclipse.kura.rest.asset.provider_${org.eclipse.kura.rest.asset.provider.version}.jar" todir="${project.build.directory}/staging/target-definition/equinox_3.16.0/repository/plugins" />
<!-- Add Artemis bundles-->
Expand Down
5 changes: 5 additions & 0 deletions kura/distrib/src/main/ant/build_equinox_distrib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,8 @@ fi]]>
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.command.provider_${org.eclipse.kura.rest.command.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
value=", reference:file:${kura.install.dir}/${kura.symlink}/${plugins.folder}/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar@4:start" />
<entry key="osgi.bundles" operation="+"
Expand Down Expand Up @@ -1414,6 +1416,9 @@ fi]]>
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.position.provider_${org.eclipse.kura.rest.position.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.security.provider_${org.eclipse.kura.rest.security.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
<zipfileset
file="${project.build.directory}/plugins/org.eclipse.kura.rest.system.provider_${org.eclipse.kura.rest.system.provider.version}.jar"
prefix="${build.output.name}/${plugins.folder}" />
Expand Down
24 changes: 24 additions & 0 deletions kura/org.eclipse.kura.rest.security.provider/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Security REST Service
Bundle-SymbolicName: org.eclipse.kura.rest.security.provider;singleton:=true
Bundle-Version: 1.0.0.qualifier
Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"
Bundle-ClassPath: .
Bundle-ActivationPolicy: lazy
Service-Component: OSGI-INF/*.xml
Import-Package: javax.annotation.security;version="1.2.0",
javax.ws.rs;version="2.0.1",
javax.ws.rs.core;version="2.0.1",
org.apache.commons.io;version="2.4.0",
org.eclipse.kura;version="[1.3,2.0)",
org.eclipse.kura.cloudconnection.request;version="[1.0,2.0)",
org.eclipse.kura.request.handler.jaxrs;version="[1.0,2.0)",
org.eclipse.kura.request.handler.jaxrs.annotation;version="[1.0,2.0)",
org.eclipse.kura.rest.configuration.api;version="[1.0,2.0)",
org.eclipse.kura.security;version="[1.1,2.0)",
org.osgi.framework;version="1.8.0",
org.osgi.service.cm;version="1.6.0",
org.osgi.service.component;version="[1.3,2.0)",
org.osgi.service.useradmin;version="1.1.0";resolution:=optional,
org.slf4j;version="1.7.25"
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Eurotech and/or its affiliates and others
This program and the accompanying materials are made
available under the terms of the Eclipse Public License 2.0
which is available at https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Contributors:
Eurotech
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.kura.internal.rest.security.provider.SecurityRestService">
<implementation class="org.eclipse.kura.internal.rest.security.provider.SecurityRestService"/>

<property name="kura.service.pid" type="String" value="org.eclipse.kura.internal.rest.security.provider.SecurityRestService"/>

<reference interface="org.eclipse.kura.cloudconnection.request.RequestHandlerRegistry"
bind="bindRequestHandlerRegistry"
unbind="unbindRequestHandlerRegistry"
cardinality="0..n"
name="RequestHandlerRegistry"
policy="dynamic"/>

<reference interface="org.eclipse.kura.security.SecurityService"
bind="bindSecurityService"
cardinality="0..1"
name="SecurityService"
policy="static"/>

<reference interface="org.osgi.service.useradmin.UserAdmin"
bind="bindUserAdmin"
cardinality="0..1"
name="UserAdmin"
policy="static"/>

<service>
<provide interface="org.eclipse.kura.internal.rest.security.provider.SecurityRestService"/>
</service>

<property name="service.pid"
type="String"
value="org.eclipse.kura.internal.rest.security.provider.SecurityRestService"/>

</scr:component>
36 changes: 36 additions & 0 deletions kura/org.eclipse.kura.rest.security.provider/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>About</title>
</head>
<body lang="EN-US">
<h2>About This Content</h2>

<p>November 30, 2017</p>
<h3>License</h3>

<p>
The Eclipse Foundation makes available all content in this plug-in
(&quot;Content&quot;). Unless otherwise indicated below, the Content
is provided to you under the terms and conditions of the Eclipse
Public License Version 2.0 (&quot;EPL&quot;). A copy of the EPL is
available at <a href="http://www.eclipse.org/legal/epl-2.0">http://www.eclipse.org/legal/epl-2.0</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.
</p>

<p>
If you did not receive this Content directly from the Eclipse
Foundation, the Content is being redistributed by another party
(&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the
Redistributor's license that was provided with the Content. If no such
license exists, contact the Redistributor. Unless otherwise indicated
below, the terms and conditions of the EPL still apply to any source
code in the Content and such source code may be obtained at <a
href="http://www.eclipse.org/">http://www.eclipse.org</a>.
</p>

</body>
</html>
Loading

0 comments on commit 25ca1a2

Please sign in to comment.