aboutsummaryrefslogtreecommitdiff
path: root/src/org/apache/harmony/javax/security/auth/AuthPermission.java
blob: bb12554fc8aef2b4773c09ce2c869662f967aedb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.apache.harmony.javax.security.auth;

import java.security.BasicPermission;



/**
 * Governs the use of methods in this package and also its subpackages. A
 * <i>target name</i> of the permission specifies which methods are allowed
 * without specifying the concrete action lists. Possible target names and
 * associated authentication permissions are:
 *
 * <pre>
 *    doAs                      invoke Subject.doAs methods.
 *    doAsPrivileged            invoke the Subject.doAsPrivileged methods.
 *    getSubject                invoke Subject.getSubject().
 *    getSubjectFromDomainCombiner    invoke SubjectDomainCombiner.getSubject().
 *    setReadOnly               invoke Subject.setReadonly().
 *    modifyPrincipals          modify the set of principals
 *                              associated with a Subject.
 *    modifyPublicCredentials   modify the set of public credentials
 *                              associated with a Subject.
 *    modifyPrivateCredentials  modify the set of private credentials
 *                              associated with a Subject.
 *    refreshCredential         invoke the refresh method on a credential of a
 *                              refreshable credential class.
 *    destroyCredential         invoke the destroy method on a credential of a
 *                              destroyable credential class.
 *    createLoginContext.<i>name</i>   instantiate a LoginContext with the
 *                              specified name. The wildcard name ('*')
 *                              allows to a LoginContext of any name.
 *    getLoginConfiguration     invoke the getConfiguration method of
 *                              javax.security.auth.login.Configuration.
 *    refreshLoginConfiguration Invoke the refresh method of
 *                              javax.security.auth.login.Configuration.
 * </pre>
 */
public final class AuthPermission extends BasicPermission {

    private static final long serialVersionUID = 5806031445061587174L;

    private static final String CREATE_LOGIN_CONTEXT = "createLoginContext"; //$NON-NLS-1$

    private static final String CREATE_LOGIN_CONTEXT_ANY = "createLoginContext.*"; //$NON-NLS-1$

    // inits permission name.
    private static String init(String name) {

        if (name == null) {
            throw new NullPointerException("auth.13"); //$NON-NLS-1$
        }

        if (CREATE_LOGIN_CONTEXT.equals(name)) {
            return CREATE_LOGIN_CONTEXT_ANY;
        }
        return name;
    }

    /**
     * Creates an authentication permission with the specified target name.
     *
     * @param name
     *            the target name of this authentication permission.
     */
    public AuthPermission(String name) {
        super(init(name));
    }

    /**
     * Creates an authentication permission with the specified target name.
     *
     * @param name
     *            the target name of this authentication permission.
     * @param actions
     *            this parameter is ignored and should be {@code null}.
     */
    public AuthPermission(String name, String actions) {
        super(init(name), actions);
    }
}