Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top