]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/security/login/BundleContextCallbackHandler.java
Move Jackrabbit security model
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / security / login / BundleContextCallbackHandler.java
1 package org.argeo.security.login;
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 /**
12 * {@link CallbackHandler} that simply wraps a {@link BundleContext} and inject
13 * it in provided {@link BundleContextCallback}
14 */
15 public class BundleContextCallbackHandler implements CallbackHandler {
16 private BundleContext bundleContext;
17
18 public BundleContextCallbackHandler() {
19 }
20
21 public BundleContextCallbackHandler(BundleContext bundleContext) {
22 super();
23 this.bundleContext = bundleContext;
24 }
25
26 @Override
27 public void handle(Callback[] callbacks) throws IOException,
28 UnsupportedCallbackException {
29 for (Callback callback : callbacks) {
30 if (callback instanceof BundleContextCallback)
31 ((BundleContextCallback) callback)
32 .setBundleContext(bundleContext);
33 }
34
35 }
36
37 public void setBundleContext(BundleContext bundleContext) {
38 this.bundleContext = bundleContext;
39 }
40
41 }