2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.security
.login
;
18 import java
.io
.IOException
;
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
;
25 import org
.argeo
.security
.SecurityUtils
;
26 import org
.argeo
.security
.core
.InternalAuthentication
;
27 import org
.springframework
.security
.core
.Authentication
;
29 /** Login module which caches one subject per thread. */
30 public class SystemLoginModule
extends AbstractSpringLoginModule
{
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(