Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top