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