質問

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