001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 * 
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 * 
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 * 
019 */
020package org.apache.directory.ldap.client.api;
021
022
023import java.util.HashMap;
024
025import javax.security.auth.login.AppConfigurationEntry;
026import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
027import javax.security.auth.login.Configuration;
028
029
030/**
031 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
032 */
033public class Krb5LoginConfiguration extends Configuration
034{
035
036    /** The list with configuration entries. */
037    private static AppConfigurationEntry[] configList = new AppConfigurationEntry[1];
038
039
040    /**
041     * Creates a new instance of Krb5LoginConfiguration.
042     */
043    public Krb5LoginConfiguration()
044    {
045        String loginModule = "com.sun.security.auth.module.Krb5LoginModule";
046
047        HashMap<String, Object> options = new HashMap<>();
048
049        // TODO: this only works for Sun JVM
050        options.put( "refreshKrb5Config", "true" );
051
052        LoginModuleControlFlag flag = LoginModuleControlFlag.REQUIRED;
053        configList[0] = new AppConfigurationEntry( loginModule, flag, options );
054    }
055
056
057    /**
058     * Interface method requiring us to return all the LoginModules we know about.
059     *
060     * @param applicationName the application name
061     * @return the configuration entry
062     */
063    @Override
064    public AppConfigurationEntry[] getAppConfigurationEntry( String applicationName )
065    {
066        // We will ignore the applicationName, since we want all apps to use Kerberos V5
067        return configList;
068    }
069
070
071    /**
072     * Interface method for reloading the configuration.  We don't need this.
073     */
074    @Override
075    public void refresh()
076    {
077        // Right now this is a load once scheme and we will not implement the refresh method
078    }
079}