jdk/test/sun/security/provider/PolicyParser/TokenStore.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 30820 0d4717a011d3
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4919147
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Support for token-based KeyStores
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.security.provider.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
public class TokenStore {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    private static final String POLICY_NO_STORE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        "grant { permission java.security.AllPermission; };";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private static final String POLICY_URL =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        "keystore \"file:${test.src}${/}TokenStore.keystore\";"         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        "grant signedby \"POLICY_URL\" {"                               +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    private static final String POLICY_URL_T =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        "keystore \"file:${test.src}${/}TokenStore.keystore\", \"JKS\";"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        "grant signedby \"POLICY_URL_T\" {"                             +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private static final String POLICY_URL_T_P =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        "keystore \"file:${test.src}${/}TokenStore.keystore\","         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        "               \"JKS\", \"SUN\";"                              +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private static final String POLICY_URL_PWD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        "keystore \"file:${test.src}${/}TokenStore.keystore\";"         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        "grant signedby \"POLICY_URL\" {"                               +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static final String POLICY_URL_T_P_PWD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        "keystore \"file:${test.src}${/}TokenStore.keystore\","         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        "               \"JKS\", \"SUN\";"                              +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    private static final String POLICY_PASS_NO_STORE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        // test no key store in policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        PolicyParser p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        p.read(new StringReader(POLICY_NO_STORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        doNoStore(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        StringWriter sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        PolicyParser newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        doNoStore(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        // test policy keystore + URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        p.read(new StringReader(POLICY_URL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        doURL(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        doURL(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        // test policy keystore + URL + type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        p.read(new StringReader(POLICY_URL_T));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        doURL_T(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        doURL_T(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // test policy keystore + URL + type + provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        p.read(new StringReader(POLICY_URL_T_P));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        doURL_T_P(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        doURL_T_P(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        // test policy keystore + URL + password
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        p.read(new StringReader(POLICY_URL_PWD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        doURL(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        doURL(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        // test policy keystore + URL + type + provider + password
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        p.read(new StringReader(POLICY_URL_T_P_PWD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        doURL_T_P(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        doURL_T_P(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        // test policy password with no keystore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            p.read(new StringReader(POLICY_PASS_NO_STORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            throw new SecurityException("expected parsing exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        } catch (PolicyParser.ParsingException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            // good
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private static void checkPerm(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        Enumeration e = p.grantElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        boolean foundOne = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        while (e.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            PolicyParser.GrantEntry ge = (PolicyParser.GrantEntry)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                                        e.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            if (ge.permissionEntries == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                throw new SecurityException("expected non-null perms");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                foundOne = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        if (!foundOne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            throw new SecurityException("expected non-null grant entries");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    private static void doNoStore(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (p.getKeyStoreUrl() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            p.getKeyStoreType() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            p.getKeyStoreProvider() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            throw new SecurityException("expected null keystore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    private static void doURL(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                throws  Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            p.getKeyStoreType() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            p.getKeyStoreProvider() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    private static void doURL_T(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            p.getKeyStoreType() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            !(p.getKeyStoreType().equals("JKS")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            p.getKeyStoreProvider() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private static void doURL_T_P(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            p.getKeyStoreType() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            !(p.getKeyStoreType().equals("JKS")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            p.getKeyStoreProvider() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            !(p.getKeyStoreProvider().equals("SUN"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    private static void doPwd(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        if (p.getStorePassURL() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            !(p.getStorePassURL().endsWith("TokenStore.pwd"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            throw new SecurityException("invalid password values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
}