]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/osgi/auth/BundleContextCallbackHander.java
- Introduce PKI utils
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / osgi / auth / BundleContextCallbackHander.java
1 package org.argeo.osgi.auth;
2
3 import java.io.IOException;
4
5 import javax.security.auth.callback.Callback;
6 import javax.security.auth.callback.CallbackHandler;
7 import javax.security.auth.callback.UnsupportedCallbackException;
8
9 import org.osgi.framework.BundleContext;
10
11 public class BundleContextCallbackHander implements CallbackHandler {
12 private final BundleContext bundleContext;
13
14 public BundleContextCallbackHander(BundleContext bundleContext) {
15 this.bundleContext = bundleContext;
16 }
17
18 @Override
19 public void handle(Callback[] callbacks) throws IOException,
20 UnsupportedCallbackException {
21 for (Callback callback : callbacks) {
22 if (!(callback instanceof BundleContextCallback))
23 throw new UnsupportedCallbackException(callback);
24 ((BundleContextCallback) callback).setBundleContext(bundleContext);
25 }
26
27 }
28
29 }