I am trying to secure my rest service in Karaf with deltaspike security
https://deltaspike.apache.org/documentation/security.html
***Custom Authorizer***
import javax.enterprise.context.ApplicationScoped;
import org.apache.deltaspike.security.api.authorization.Secures;
@ApplicationScoped
public class CustomAuthorizer
{
@Secures
@UserLoggedIn
public boolean doSecuredCheck() throws Exception
{
System.out.println("Called");
return true;
}
}
***Custom Annotation** @UserLoggedIn*
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import
org.apache.deltaspike.security.api.authorization.SecurityBindingType;
@Retention(value = RUNTIME)
@Target({TYPE, METHOD})
@Documented
@SecurityBindingType
public @interface UserLoggedIn {}
***Rest IMPL***
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.core.Response;
import org.ops4j.pax.cdi.api.OsgiService;
import ca.esc.pbm.fe.pbm_frontend_jaxrs.api.HelloService;
import ca.esc.pbm.fe.rest.pbm_frontend_jaxrs.api.PersonService;
@Named
public class PersonServiceImpl implements PersonService {
@Inject
@OsgiService
HelloService helloService;
@UserLoggedIn
@Override
public Response getAll() {
Response response =
Response.ok("<recipe2>"+helloService.sayHello("Athish")+"</recipe2>").status(200).build();
return response;
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>ca.esc.pbm.frontend</groupId>
<artifactId>pbm-frontend-rest</artifactId>
<version>1.0</version>
</parent>
<artifactId>pbm-frontend-rest.provider</artifactId>
<packaging>bundle</packaging>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>3.1.11</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>org.apache.karaf.features.core</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>ca.esc.pbm.frontend</groupId>
<artifactId>pbm-frontend-rest.api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>ca.esc.pbm.frontend</groupId>
<artifactId>pbm-frontend-osgi.api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-api</artifactId>
<version>${deltaspike.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-impl</artifactId>
<version>${deltaspike.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-security-module-api</artifactId>
<version>${deltaspike.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.modules</groupId>
<artifactId>deltaspike-security-module-impl</artifactId>
<version>${deltaspike.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
Karaf Console like this
karaf@root()> list
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
---------------------------------------------------------------------------------------------------------------------------------
102 | Active | 80 | 1.1.1 | geronimo-jms_1.1_spec
106 | Active | 80 | 2.0.14 | Apache MINA Core
171 | Active | 80 | 1.0 | Apache Geronimo JSR-330 Spec API
176 | Active | 80 | 1.5.0 | OPS4J Base - All
177 | Active | 80 | 0.12.0 | OPS4J Pax CDI Bean Bundle API
178 | Active | 80 | 0.12.0 | OPS4J Pax CDI Extender for Bean Bundles
179 | Active | 80 | 0.12.0 | OPS4J Pax CDI Portable Extension for
OSGi
180 | Active | 80 | 0.12.0 | OPS4J Pax CDI Service Provider Interface
182 | Active | 80 | 1.8.0 | OPS4J Pax Swissbox :: OSGi Core
183 | Active | 80 | 1.8.0 | OPS4J Pax Swissbox :: Lifecycle
184 | Active | 80 | 1.8.0 | OPS4J Pax Swissbox :: Tracker
201 | Active | 80 | 1.0.0 | Front End CMD
202 | Active | 80 | 1.0.0 | test-frontend-osgi.api
203 | Active | 80 | 1.0.0 | test-frontend-osgi.provider
204 | Active | 80 | 13.0.1 | Guava: Google Core Libraries for Java
205 | Active | 80 | 3.0.0 | Expression Language 3.0 API
206 | Active | 80 | 1.2.0 | CDI APIs
207 | Active | 80 | 1.2 | javax.interceptor API
208 | Active | 80 | 3.1.3.GA | JBoss Logging 3
209 | Active | 80 | 2.2.4.Final | Weld OSGi Bundle
210 | Active | 80 | 0.12.0 | OPS4J Pax CDI Weld Adapter
211 | Active | 80 | 0 |
wrap_file__C__Users_anharayanan_.m2_repository_javax_inject_javax.inject_1_javax.inject-1.jar
213 | Active | 80 | 1.7.2 | deltaspike-core-api
214 | Active | 80 | 1.7.2 | deltaspike-core-impl
215 | Active | 80 | 1.7.2 | deltaspike-security-module-api
216 | Active | 80 | 1.7.2 | deltaspike-security-module-impl
224 | Failure | 80 | 1.0.0 | PBM Rest IMPL
I am getting the following Error
karaf@root()> install -s mvn:ca.frontend/test-frontend-rest.provider/1.0
ERROR: Bundle org.ops4j.pax.cdi.extender [178] EventDispatcher: Error during
dispatch. (org.ops4j.lang.Ops4jException:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied
dependencies for type SecurityExtension with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension
at
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension(DefaultSecurityStrategy.java:0)
)
org.ops4j.lang.Ops4jException:
org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied
dependencies for type SecurityExtension with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension
at
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension(DefaultSecurityStrategy.java:0)
at
org.ops4j.pax.cdi.weld.impl.WeldCdiContainer.doStart(WeldCdiContainer.java:99)
at
org.ops4j.pax.cdi.spi.AbstractCdiContainer.start(AbstractCdiContainer.java:89)
at
org.ops4j.pax.cdi.extender.impl.CdiExtender.createContainer(CdiExtender.java:132)
at
org.ops4j.pax.cdi.extender.impl.CdiExtender.addingBundle(CdiExtender.java:86)
at
org.ops4j.pax.cdi.extender.impl.CdiExtender.addingBundle(CdiExtender.java:44)
at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
at
org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:415)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
at
org.apache.felix.framework.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:915)
at
org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:834)
at
org.apache.felix.framework.EventDispatcher.fireBundleEvent(EventDispatcher.java:516)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4541)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2172)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
at org.apache.karaf.bundle.command.Install.execute(Install.java:96)
at
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:83)
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:67)
at
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:87)
at
org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:480)
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:406)
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:182)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:119)
at
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:94)
at
org.apache.karaf.shell.impl.console.ConsoleSessionImpl.run(ConsoleSessionImpl.java:274)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408:
Unsatisfied dependencies for type SecurityExtension with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension
at
org.apache.deltaspike.security.impl.extension.DefaultSecurityStrategy.securityExtension(DefaultSecurityStrategy.java:0)
at
org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:370)
at
org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:291)
at
org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
at
org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:165)
at
org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:529)
at
org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
at
org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
at
org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
at
org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
... 1 more
--
View this message in context:
http://apache-deltaspike-incubator-discussions.2316169.n4.nabble.com/org-jboss-weld-exceptions-DeploymentException-WELD-001408-Unsatisfied-dependencies-for-type-Securityn-tp4663963.html
Sent from the Apache DeltaSpike Incubator Discussions mailing list archive at
Nabble.com.