]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/security/login/SystemLoginModule.java
Move Jackrabbit security model
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / security / login / SystemLoginModule.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.security.login;
17
18 import java.io.IOException;
19
20 import javax.security.auth.callback.Callback;
21 import javax.security.auth.callback.CallbackHandler;
22 import javax.security.auth.callback.UnsupportedCallbackException;
23 import javax.security.auth.login.LoginException;
24
25 import org.argeo.security.SecurityUtils;
26 import org.argeo.security.core.InternalAuthentication;
27 import org.springframework.security.core.Authentication;
28
29 /** Login module which caches one subject per thread. */
30 public class SystemLoginModule extends AbstractSpringLoginModule {
31 @Override
32 protected Authentication processLogin(CallbackHandler callbackHandler)
33 throws LoginException, UnsupportedCallbackException, IOException,
34 InterruptedException {
35 BundleContextCallback bundleContextCallback = new BundleContextCallback();
36 callbackHandler.handle(new Callback[] { bundleContextCallback });
37 InternalAuthentication anonymousToken = new InternalAuthentication(
38 SecurityUtils.getStaticKey());
39 return getAuthenticationManager(bundleContextCallback).authenticate(
40 anonymousToken);
41 }
42 }