blob: 2a735dc45ca50d02c510a0d713c6fb8463b57ac2 [file] [log] [blame]
Shuyi Chend7955ce2013-05-22 14:51:55 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package org.apache.harmony.javax.security.auth.login;
19
20import java.util.Collections;
21import java.util.Map;
22
23
24
25public class AppConfigurationEntry {
26
27 // the login module options
28 private final Map<String, ?> options;
29
30 // the control flag
31 private final AppConfigurationEntry.LoginModuleControlFlag controlFlag;
32
33 // the login module name
34 private final String loginModuleName;
35
36 public AppConfigurationEntry(String loginModuleName,
37 AppConfigurationEntry.LoginModuleControlFlag controlFlag, Map<String, ?> options) {
38
39 if (loginModuleName == null || loginModuleName.length() == 0) {
40 throw new IllegalArgumentException("auth.26"); //$NON-NLS-1$
41 }
42
43 if (controlFlag == null) {
44 throw new IllegalArgumentException("auth.27"); //$NON-NLS-1$
45 }
46
47 if (options == null) {
48 throw new IllegalArgumentException("auth.1A"); //$NON-NLS-1$
49 }
50
51 this.loginModuleName = loginModuleName;
52 this.controlFlag = controlFlag;
53 this.options = Collections.unmodifiableMap(options);
54 }
55
56 public String getLoginModuleName() {
57 return loginModuleName;
58 }
59
60 public LoginModuleControlFlag getControlFlag() {
61 return controlFlag;
62 }
63
64 public Map<java.lang.String, ?> getOptions() {
65 return options;
66 }
67
68 public static class LoginModuleControlFlag {
69
70 // the control flag
71 private final String flag;
72
73 public static final LoginModuleControlFlag REQUIRED = new LoginModuleControlFlag(
74 "LoginModuleControlFlag: required"); //$NON-NLS-1$
75
76 public static final LoginModuleControlFlag REQUISITE = new LoginModuleControlFlag(
77 "LoginModuleControlFlag: requisite"); //$NON-NLS-1$
78
79 public static final LoginModuleControlFlag OPTIONAL = new LoginModuleControlFlag(
80 "LoginModuleControlFlag: optional"); //$NON-NLS-1$
81
82 public static final LoginModuleControlFlag SUFFICIENT = new LoginModuleControlFlag(
83 "LoginModuleControlFlag: sufficient"); //$NON-NLS-1$
84
85 // Creates the LoginModuleControlFlag object with specified a flag
86 private LoginModuleControlFlag(String flag) {
87 this.flag = flag;
88 }
89
90 @Override
91 public String toString() {
92 return flag;
93 }
94 }
95}