Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/security/auth/login/AppConfigurationEntry.java
38918 views
/*1* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.security.auth.login;2627import java.util.Map;28import java.util.Collections;2930/**31* This class represents a single {@code LoginModule} entry32* configured for the application specified in the33* {@code getAppConfigurationEntry(String appName)}34* method in the {@code Configuration} class. Each respective35* {@code AppConfigurationEntry} contains a {@code LoginModule} name,36* a control flag (specifying whether this {@code LoginModule} is37* REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL), and LoginModule-specific38* options. Please refer to the {@code Configuration} class for39* more information on the different control flags and their semantics.40*41* @see javax.security.auth.login.Configuration42*/43public class AppConfigurationEntry {4445private String loginModuleName;46private LoginModuleControlFlag controlFlag;47private Map<String,?> options;4849/**50* Default constructor for this class.51*52* <p> This entry represents a single {@code LoginModule}53* entry configured for the application specified in the54* {@code getAppConfigurationEntry(String appName)}55* method from the {@code Configuration} class.56*57* @param loginModuleName String representing the class name of the58* {@code LoginModule} configured for the59* specified application. <p>60*61* @param controlFlag either REQUIRED, REQUISITE, SUFFICIENT,62* or OPTIONAL. <p>63*64* @param options the options configured for this {@code LoginModule}.65*66* @exception IllegalArgumentException if {@code loginModuleName}67* is null, if {@code LoginModuleName}68* has a length of 0, if {@code controlFlag}69* is not either REQUIRED, REQUISITE, SUFFICIENT70* or OPTIONAL, or if {@code options} is null.71*/72public AppConfigurationEntry(String loginModuleName,73LoginModuleControlFlag controlFlag,74Map<String,?> options)75{76if (loginModuleName == null || loginModuleName.length() == 0 ||77(controlFlag != LoginModuleControlFlag.REQUIRED &&78controlFlag != LoginModuleControlFlag.REQUISITE &&79controlFlag != LoginModuleControlFlag.SUFFICIENT &&80controlFlag != LoginModuleControlFlag.OPTIONAL) ||81options == null)82throw new IllegalArgumentException();8384this.loginModuleName = loginModuleName;85this.controlFlag = controlFlag;86this.options = Collections.unmodifiableMap(options);87}8889/**90* Get the class name of the configured {@code LoginModule}.91*92* @return the class name of the configured {@code LoginModule} as93* a String.94*/95public String getLoginModuleName() {96return loginModuleName;97}9899/**100* Return the controlFlag101* (either REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL)102* for this {@code LoginModule}.103*104* @return the controlFlag105* (either REQUIRED, REQUISITE, SUFFICIENT, or OPTIONAL)106* for this {@code LoginModule}.107*/108public LoginModuleControlFlag getControlFlag() {109return controlFlag;110}111112/**113* Get the options configured for this {@code LoginModule}.114*115* @return the options configured for this {@code LoginModule}116* as an unmodifiable {@code Map}.117*/118public Map<String,?> getOptions() {119return options;120}121122/**123* This class represents whether or not a {@code LoginModule}124* is REQUIRED, REQUISITE, SUFFICIENT or OPTIONAL.125*/126public static class LoginModuleControlFlag {127128private String controlFlag;129130/**131* Required {@code LoginModule}.132*/133public static final LoginModuleControlFlag REQUIRED =134new LoginModuleControlFlag("required");135136/**137* Requisite {@code LoginModule}.138*/139public static final LoginModuleControlFlag REQUISITE =140new LoginModuleControlFlag("requisite");141142/**143* Sufficient {@code LoginModule}.144*/145public static final LoginModuleControlFlag SUFFICIENT =146new LoginModuleControlFlag("sufficient");147148/**149* Optional {@code LoginModule}.150*/151public static final LoginModuleControlFlag OPTIONAL =152new LoginModuleControlFlag("optional");153154private LoginModuleControlFlag(String controlFlag) {155this.controlFlag = controlFlag;156}157158/**159* Return a String representation of this controlFlag.160*161* <p> The String has the format, "LoginModuleControlFlag: <i>flag</i>",162* where <i>flag</i> is either <i>required</i>, <i>requisite</i>,163* <i>sufficient</i>, or <i>optional</i>.164*165* @return a String representation of this controlFlag.166*/167public String toString() {168return (sun.security.util.ResourcesMgr.getString169("LoginModuleControlFlag.") + controlFlag);170}171}172}173174175