AuthPermission.java 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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;
  18. import java.security.BasicPermission;
  19. import org.apache.harmony.auth.internal.nls.Messages;
  20. /**
  21. * Governs the use of methods in this package and also its subpackages. A
  22. * <i>target name</i> of the permission specifies which methods are allowed
  23. * without specifying the concrete action lists. Possible target names and
  24. * associated authentication permissions are:
  25. *
  26. * <pre>
  27. * doAs invoke Subject.doAs methods.
  28. * doAsPrivileged invoke the Subject.doAsPrivileged methods.
  29. * getSubject invoke Subject.getSubject().
  30. * getSubjectFromDomainCombiner invoke SubjectDomainCombiner.getSubject().
  31. * setReadOnly invoke Subject.setReadonly().
  32. * modifyPrincipals modify the set of principals
  33. * associated with a Subject.
  34. * modifyPublicCredentials modify the set of public credentials
  35. * associated with a Subject.
  36. * modifyPrivateCredentials modify the set of private credentials
  37. * associated with a Subject.
  38. * refreshCredential invoke the refresh method on a credential of a
  39. * refreshable credential class.
  40. * destroyCredential invoke the destroy method on a credential of a
  41. * destroyable credential class.
  42. * createLoginContext.<i>name</i> instantiate a LoginContext with the
  43. * specified name. The wildcard name ('*')
  44. * allows to a LoginContext of any name.
  45. * getLoginConfiguration invoke the getConfiguration method of
  46. * javax.security.auth.login.Configuration.
  47. * refreshLoginConfiguration Invoke the refresh method of
  48. * javax.security.auth.login.Configuration.
  49. * </pre>
  50. */
  51. public final class AuthPermission extends BasicPermission {
  52. private static final long serialVersionUID = 5806031445061587174L;
  53. private static final String CREATE_LOGIN_CONTEXT = "createLoginContext"; //$NON-NLS-1$
  54. private static final String CREATE_LOGIN_CONTEXT_ANY = "createLoginContext.*"; //$NON-NLS-1$
  55. // inits permission name.
  56. private static String init(String name) {
  57. if (name == null) {
  58. throw new NullPointerException(Messages.getString("auth.13")); //$NON-NLS-1$
  59. }
  60. if (CREATE_LOGIN_CONTEXT.equals(name)) {
  61. return CREATE_LOGIN_CONTEXT_ANY;
  62. }
  63. return name;
  64. }
  65. /**
  66. * Creates an authentication permission with the specified target name.
  67. *
  68. * @param name
  69. * the target name of this authentication permission.
  70. */
  71. public AuthPermission(String name) {
  72. super(init(name));
  73. }
  74. /**
  75. * Creates an authentication permission with the specified target name.
  76. *
  77. * @param name
  78. * the target name of this authentication permission.
  79. * @param actions
  80. * this parameter is ignored and should be {@code null}.
  81. */
  82. public AuthPermission(String name, String actions) {
  83. super(init(name), actions);
  84. }
  85. }