javaosgiamdatu

Amdatu TokenProvider


Hello been looking at the example of osgi webapp built with Amdatu framwork is available at this ShowCase even though an implementation performing exactly like the example every time the service instance is always null. Also I had read the documentation on the security module Amdatu but was unable to configure it, does anyone have a walkthrough on how to use the TokenProvider is made?

Thank you

ShowCase Link

Amdatu Security Doc

When execute dm notavail command i gets:

[1] agenda.web.filters
  javax.servlet.Filter(pattern=/*.*) unregistered
    org.amdatu.security.tokenprovider.TokenProvider service required unavailable
[15] org.amdatu.security.tokenprovider.impl
  org.amdatu.security.tokenprovider.TokenProvider unregistered
    org.amdatu.security.tokenprovider configuration required available
    org.amdatu.security.tokenprovider.TokenStorageProvider service required unavailable
    org.osgi.service.log.LogService service optional (not tracking)
[16] org.amdatu.security.tokenstorage.mongo
  org.amdatu.security.tokenprovider.TokenStorageProvider, org.amdatu.security.tokenstorage.mongo.ExpiredTokenPurger unregistered
    org.amdatu.mongo.MongoDBService service required unavailable
    org.osgi.service.log.LogService service optional (not tracking)
  org.quartz.Job unregistered
    org.amdatu.security.tokenstorage.mongo.ExpiredTokenPurger service required unavailable
    org.osgi.service.log.LogService service optional (not tracking)

My Activator is this:

import java.util.Properties;

import javax.servlet.Filter;

import org.amdatu.security.tokenprovider.TokenProvider;
import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;

import agenda.web.filters.teste.AdminLoginResource;
import agenda.web.filters.teste.RedirectFilter;
import agenda.web.filters.teste.SecurityFilter;

public class Activator extends DependencyActivatorBase {

    @Override
    public void init(BundleContext arg0, DependencyManager dm)
            throws Exception {

        Properties properties = new Properties();
        properties.put("pattern", "/*.*");
        dm.add(createComponent()
                .setInterface(Filter.class.getName(), properties)
                .setImplementation(SecurityFilter.class)
                .add(createServiceDependency().setService(TokenProvider.class).setRequired(true))
                .add(createServiceDependency()
                        .setService(LogService.class)
                        .setRequired(false)));

    }

    @Override
    public void destroy(BundleContext arg0, DependencyManager arg1)
            throws Exception {
        // TODO Auto-generated method stub

    }

}

Solution

  • Looking at the output of DM it seems to be the problem that the MongoDbService is not available. The MongoDbService is created by a Managed Service Factory, so you are probably missing it's configuration. At least a "dbName" should be configured, see more docs here: http://amdatu.org/components/mongodb.html