Domanda

In FUSE (or Karaf), how does one get the caller user id? I'm actually using FUSE with blueprint services.

For example, in a J2EE session bean, you can do:

sessionCtx.getCallerPrincipal()

Is there an equivalent in the OSGI service space?

È stato utile?

Soluzione

In Karaf we use plain jaas to do service authentication. So you can use the following code to access the subject and principals.

AccessControlContext acc = AccessController.getContext();
Subject subject = Subject.getSubject(acc);
Set<Principal> principals = subject.getPrincipals();

In karaf 3 there is also built in role based access control for OSGi services. So you can define which roles may access which services.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top