jdk/test/sun/security/provider/PolicyParser/TokenStore.java
author mchung
Thu, 28 May 2015 10:54:48 -0700
changeset 30820 0d4717a011d3
parent 5506 202f599c92aa
permissions -rw-r--r--
8081347: Add @modules to jdk_core tests Reviewed-by: alanb, joehw, lancea Contributed-by: alexander.kulyakhtin@oracle.com, alan.bateman@oracle.com, mandy.chung@oracle.com
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
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 5506
diff changeset
    28
 * @modules java.base/sun.security.provider
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import sun.security.provider.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
public class TokenStore {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    private static final String POLICY_NO_STORE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        "grant { permission java.security.AllPermission; };";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private static final String POLICY_URL =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        "keystore \"file:${test.src}${/}TokenStore.keystore\";"         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        "grant signedby \"POLICY_URL\" {"                               +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private static final String POLICY_URL_T =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        "keystore \"file:${test.src}${/}TokenStore.keystore\", \"JKS\";"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        "grant signedby \"POLICY_URL_T\" {"                             +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private static final String POLICY_URL_T_P =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        "keystore \"file:${test.src}${/}TokenStore.keystore\","         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        "               \"JKS\", \"SUN\";"                              +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static final String POLICY_URL_PWD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        "keystore \"file:${test.src}${/}TokenStore.keystore\";"         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        "grant signedby \"POLICY_URL\" {"                               +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private static final String POLICY_URL_T_P_PWD =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        "keystore \"file:${test.src}${/}TokenStore.keystore\","         +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        "               \"JKS\", \"SUN\";"                              +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static final String POLICY_PASS_NO_STORE =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        "keystorePasswordURL \"file:${test.src}${/}TokenStore.pwd\";"   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        "grant signedby \"POLICY_URL_T_P\" {"                           +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        "    permission java.security.AllPermission;"                   +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        "};"                                                            ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        // test no key store in policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        PolicyParser p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        p.read(new StringReader(POLICY_NO_STORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        doNoStore(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        StringWriter sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        PolicyParser newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        doNoStore(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        // test policy keystore + URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        p.read(new StringReader(POLICY_URL));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        doURL(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        doURL(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        // test policy keystore + URL + type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        p.read(new StringReader(POLICY_URL_T));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        doURL_T(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        doURL_T(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        // test policy keystore + URL + type + provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        p.read(new StringReader(POLICY_URL_T_P));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        doURL_T_P(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        doURL_T_P(p, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        // test policy keystore + URL + password
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        p.read(new StringReader(POLICY_URL_PWD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        doURL(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        doURL(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // test policy keystore + URL + type + provider + password
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        p.read(new StringReader(POLICY_URL_T_P_PWD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        doURL_T_P(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        sw = new StringWriter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        p.write(sw);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        newP = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        newP.read(new StringReader(sw.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        doURL_T_P(p, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        doPwd(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        // test policy password with no keystore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        p = new PolicyParser();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            p.read(new StringReader(POLICY_PASS_NO_STORE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            throw new SecurityException("expected parsing exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        } catch (PolicyParser.ParsingException pe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            // good
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    private static void checkPerm(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        Enumeration e = p.grantElements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        boolean foundOne = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        while (e.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            PolicyParser.GrantEntry ge = (PolicyParser.GrantEntry)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                        e.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            if (ge.permissionEntries == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                throw new SecurityException("expected non-null perms");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                foundOne = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (!foundOne) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            throw new SecurityException("expected non-null grant entries");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    private static void doNoStore(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        if (p.getKeyStoreUrl() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            p.getKeyStoreType() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            p.getKeyStoreProvider() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            throw new SecurityException("expected null keystore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private static void doURL(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                throws  Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            p.getKeyStoreType() != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            p.getKeyStoreProvider() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    private static void doURL_T(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            p.getKeyStoreType() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            !(p.getKeyStoreType().equals("JKS")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            p.getKeyStoreProvider() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    private static void doURL_T_P(PolicyParser p, boolean checkPwd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        if (p.getKeyStoreUrl() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            !(p.getKeyStoreUrl().endsWith("TokenStore.keystore")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            p.getKeyStoreType() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            !(p.getKeyStoreType().equals("JKS")) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            p.getKeyStoreProvider() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            !(p.getKeyStoreProvider().equals("SUN"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        if (checkPwd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            if (p.getStorePassURL() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                throw new SecurityException("invalid keystore values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        checkPerm(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    private static void doPwd(PolicyParser p) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if (p.getStorePassURL() == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            !(p.getStorePassURL().endsWith("TokenStore.pwd"))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            throw new SecurityException("invalid password values");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
}