AppConfigurationEntry.java 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  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. package javax.security.auth.login;
  18. import java.util.Collections;
  19. import java.util.Map;
  20. import org.apache.harmony.auth.internal.nls.Messages;
  21. public class AppConfigurationEntry {
  22. // the login module options
  23. private final Map<String, ?> options;
  24. // the control flag
  25. private final AppConfigurationEntry.LoginModuleControlFlag controlFlag;
  26. // the login module name
  27. private final String loginModuleName;
  28. public AppConfigurationEntry(String loginModuleName,
  29. AppConfigurationEntry.LoginModuleControlFlag controlFlag, Map<String, ?> options) {
  30. if (loginModuleName == null || loginModuleName.length() == 0) {
  31. throw new IllegalArgumentException(Messages.getString("auth.26")); //$NON-NLS-1$
  32. }
  33. if (controlFlag == null) {
  34. throw new IllegalArgumentException(Messages.getString("auth.27")); //$NON-NLS-1$
  35. }
  36. if (options == null) {
  37. throw new IllegalArgumentException(Messages.getString("auth.1A")); //$NON-NLS-1$
  38. }
  39. this.loginModuleName = loginModuleName;
  40. this.controlFlag = controlFlag;
  41. this.options = Collections.unmodifiableMap(options);
  42. }
  43. public String getLoginModuleName() {
  44. return loginModuleName;
  45. }
  46. public LoginModuleControlFlag getControlFlag() {
  47. return controlFlag;
  48. }
  49. public Map<java.lang.String, ?> getOptions() {
  50. return options;
  51. }
  52. public static class LoginModuleControlFlag {
  53. // the control flag
  54. private final String flag;
  55. public static final LoginModuleControlFlag REQUIRED = new LoginModuleControlFlag(
  56. "LoginModuleControlFlag: required"); //$NON-NLS-1$
  57. public static final LoginModuleControlFlag REQUISITE = new LoginModuleControlFlag(
  58. "LoginModuleControlFlag: requisite"); //$NON-NLS-1$
  59. public static final LoginModuleControlFlag OPTIONAL = new LoginModuleControlFlag(
  60. "LoginModuleControlFlag: optional"); //$NON-NLS-1$
  61. public static final LoginModuleControlFlag SUFFICIENT = new LoginModuleControlFlag(
  62. "LoginModuleControlFlag: sufficient"); //$NON-NLS-1$
  63. // Creates the LoginModuleControlFlag object with specified a flag
  64. private LoginModuleControlFlag(String flag) {
  65. this.flag = flag;
  66. }
  67. @Override
  68. public String toString() {
  69. return flag;
  70. }
  71. }
  72. }