Hi everyone,
I try to check the user’s token and roles every time he requests his items in the org.openhab.core.io.rest.auth
bundle at the /openhab-core/bundles/org.openhab.core.io.rest.auth
location in the openhab-core project, in this code fragment:
For this the org.openhab.core.io.rest.core
bundle at the location openhab-core/bundles/org.openhab.core.io.rest.core
needs the dependency of the org.openhab.core.io.rest.auth
bundle to get the token verification function. But I have a problem. The org.openhab.core.io.rest.core
bundle can’t import the required package (which is org.openhab.core.io.rest.auth
bundle) as shown below :
I added the dependency in the org.openhab.core.io.rest.core
bundle like this:
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.rest.auth</artifactId>
<version>${project.version}</version>
</dependency>
I know that the OSGi headers of each bundle are generated with Maven. But do you know how to make the org.openhab.core.io.rest.auth
bundle available for other bundles?
In the OSGi header, generated by Maven, of the bundle org.openhab.core.io.rest.auth
there is no Export-Package as shown in his manifest file, below:
Manifest-Version: 1.0
Automatic-Module-Name: org.openhab.core.io.rest.auth
Bnd-LastModified: 1647291640150
Bundle-Description: This project contains the core components of openH
AB
Bundle-Developers: openhab;email="info@openhab.org";name=openHAB;organ
ization=openHAB;organizationUrl="https://www.openHAB.org"
Bundle-DocURL: https://github.com/openhab/infrastructure/org.openhab.c
ore.reactor/org.openhab.core.reactor.bundles/org.openhab.core.io.rest
.auth
Bundle-License: "Eclipse Public License 2.0";link="https://www.eclipse
.org/legal/epl-2.0/"
Bundle-ManifestVersion: 2
Bundle-Name: openHAB Core :: Bundles :: Authentication Support for the
REST Interface
Bundle-SCM: url="https://github.com/openhab/openhab-core/org.openhab.c
ore.reactor.bundles/org.openhab.core.io.rest.auth",connection="scm:gi
t:https://github.com/openhab/openhab-core.git/org.openhab.core.reacto
r.bundles/org.openhab.core.io.rest.auth",developer-connection="scm:gi
t:https://github.com/openhab/openhab-core.git/org.openhab.core.reacto
r.bundles/org.openhab.core.io.rest.auth",tag=HEAD
Bundle-SymbolicName: org.openhab.core.io.rest.auth
Bundle-Vendor: openHAB.org
Bundle-Version: 3.3.0.202203142100
Created-By: 11.0.14 (Ubuntu)
Import-Package: io.swagger.v3.oas.annotations;resolution:=optional;ver
sion="[2.1,3)",io.swagger.v3.oas.annotations.media;resolution:=option
al;version="[2.1,3)",io.swagger.v3.oas.annotations.responses;resoluti
on:=optional;version="[2.1,3)",io.swagger.v3.oas.annotations.tags;res
olution:=optional;version="[2.1,3)",javax.annotation.security;resolut
ion:=optional;version="[1.2,2)",javax.annotation;version="[1.2,2)",ja
vax.ws.rs,javax.ws.rs.container,javax.ws.rs.core,javax.ws.rs.ext,org.
jose4j.base64url;version="[0.7,1)",org.jose4j.jwa;version="[0.7,1)",o
rg.jose4j.jwk;version="[0.7,1)",org.jose4j.jws;version="[0.7,1)",org.
jose4j.jwt;version="[0.7,1)",org.jose4j.jwt.consumer;version="[0.7,1)
",org.jose4j.lang;version="[0.7,1)",org.openhab.core;version="[3.3,4)
",org.openhab.core.auth;version="[3.3,4)",org.openhab.core.common.reg
istry;version="[3.3,4)",org.openhab.core.io.rest;version="[3.3,4)",or
g.slf4j;version="[1.7,2)"
Private-Package: OH-INF.config,OH-INF.i18n,org.openhab.core.io.rest.au
th.internal
Provide-Capability: osgi.service;objectClass:List<String>="javax.ws.rs
.container.DynamicFeature";uses:="javax.ws.rs.container",osgi.service
;objectClass:List<String>="org.openhab.core.io.rest.RESTResource,org.
openhab.core.io.rest.auth.internal.TokenResource";uses:="org.openhab.
core.io.rest,org.openhab.core.io.rest.auth.internal",osgi.service;obj
ectClass:List<String>="org.openhab.core.io.rest.auth.internal.AuthFil
ter";uses:="org.openhab.core.io.rest.auth.internal",osgi.service;obje
ctClass:List<String>="org.openhab.core.io.rest.auth.internal.JwtHelpe
r";uses:="org.openhab.core.io.rest.auth.internal"
Require-Capability: osgi.service;filter:="(objectClass=org.openhab.cor
e.auth.UserRegistry)";effective:=active,osgi.service;filter:="(object
Class=org.openhab.core.io.rest.auth.internal.JwtHelper)";effective:=a
ctive,osgi.extender;filter:="(&(osgi.extender=osgi.component)(version
>=1.4.0)(!(version>=2.0.0)))",osgi.implementation;filter:="(&(osgi.im
plementation=osgi.jaxrs)(version>=1.0.0)(!(version>=2.0.0)))",osgi.se
rvice;filter:="(osgi.jaxrs.media.type=application/json)";resolution:=
optional;effective:=active,osgi.contract;osgi.contract=JavaJAXRS;filt
er:="(&(osgi.contract=JavaJAXRS)(version=2.1.0))",osgi.ee;filter:="(&
(osgi.ee=JavaSE)(version=11))"
Service-Component: OSGI-INF/org.openhab.core.io.rest.auth.internal.Aut
hFilter.xml,OSGI-INF/org.openhab.core.io.rest.auth.internal.JwtHelper
.xml,OSGI-INF/org.openhab.core.io.rest.auth.internal.RolesAllowedDyna
micFeatureImpl.xml,OSGI-INF/org.openhab.core.io.rest.auth.internal.To
kenResource.xml
Tool: Bnd-6.1.0.202111221555
Do you know how to configure the pom.xml file to make the org.openhab.core.io.rest.auth
bundle available to other bundles, by exporting its packages?
In the feature.xml file at the location openhab-core/features/karaf/openhab-core/src/main/feature/feature.xml, I added the dependency openhab-core-io-rest-auth
but it does not work.
I tried to add the following lines in the pom.xml of the openhab-core-io-rest-auth
bundle to make its packages available.
<build>
<plugins>
<plugin>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.rest.auth</artifactId>
<version>3.3.0-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<manifestLocation>./target/classes/META-INF/MANIFEST.MF</manifestLocation>
<instructions>
<Export-Package>*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
But it doesn’t work too.
So anyone know what I need to do so that Maven will add the Export-Package entry in the OSGi header of the openhab-core-io-rest-auth
bundle to export all its packages and make them available to other bundles?
I hoop I have been clear.
Thank you,
Nicolas Gennart.