- if (authenticationManager != null) {
- Authentication auth = authenticationManager
- .authenticate(new InternalAuthentication(key));
- securityContext.setAuthentication(auth);
- } else {
- try {
- // TODO test this
- if (bundleContext == null)
- throw new ArgeoException("bundleContext must be set");
- BundleContextCallbackHandler callbackHandler = new BundleContextCallbackHandler(
- bundleContext);
- LoginContext loginContext = new LoginContext(loginContextName,
- callbackHandler);
- loginContext.login();
- } catch (LoginException e) {
- throw new BadCredentialsException("Cannot authenticate");
- }
- }
+ if (authenticationManager == null)
+ throw new ArgeoException("Authentication manager cannot be null.");
+ Authentication auth = authenticationManager
+ .authenticate(new InternalAuthentication(key));
+ securityContext.setAuthentication(auth);
+