org.apache.felix.jaas.LoginContextFactory Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.felix.jaas;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import aQute.bnd.annotation.ProviderType;
/**
* A factory for creating {@link LoginContext} instances.
*
* Instead of directly creating {@link LoginContext} this factory can be used. It takes care of
* locating the {@link javax.security.auth.login.Configuration} instance and switching of Thread's context
* classloader.
*/
@ProviderType
public interface LoginContextFactory
{
/**
* Instantiate a new LoginContext
object with a name, a Subject
to be authenticated,
* and a CallbackHandler
object.
*
* @param realm realm or application name
* @param subject the Subject
to authenticate.
* @param handler the CallbackHandler
object used by
* LoginModules to communicate with the user.
*
* @return created LoginContext
*
* @exception LoginException if the caller-specified name
does not appear in
* the Configuration
and there is no Configuration
entry
* for "other", or if the caller-specified subject
is null
,
* or if the caller-specified callbackHandler
is null
.
*/
LoginContext createLoginContext(String realm, Subject subject, CallbackHandler handler) throws LoginException;
}