src/java.base/share/classes/sun/security/provider/PolicyFile.java
changeset 48757 8cc67294ec56
parent 48080 18a4438eb690
child 49150 a4a816f88e58
equal deleted inserted replaced
48756:ce608a09a666 48757:8cc67294ec56
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   578             // record bad policy file to avoid later reparsing it
   578             // record bad policy file to avoid later reparsing it
   579             badPolicyURLs.updateAndGet(k -> {
   579             badPolicyURLs.updateAndGet(k -> {
   580                 k.add(policy);
   580                 k.add(policy);
   581                 return k;
   581                 return k;
   582             });
   582             });
   583             Object[] source = {policy, pe.getLocalizedMessage()};
   583             Object[] source = {policy, pe.getNonlocalizedMessage()};
   584             System.err.println(LocalizedMessage.getMessage
   584             System.err.println(LocalizedMessage.getNonlocalized
   585                 (POLICY + ".error.parsing.policy.message", source));
   585                 (POLICY + ".error.parsing.policy.message", source));
   586             if (debug != null) {
   586             if (debug != null) {
   587                 pe.printStackTrace();
   587                 pe.printStackTrace();
   588             }
   588             }
   589         } catch (Exception e) {
   589         } catch (Exception e) {
   806                     }
   806                     }
   807                 } catch (java.lang.reflect.InvocationTargetException ite) {
   807                 } catch (java.lang.reflect.InvocationTargetException ite) {
   808                     Object[] source = {pe.permission,
   808                     Object[] source = {pe.permission,
   809                                        ite.getTargetException().toString()};
   809                                        ite.getTargetException().toString()};
   810                     System.err.println(
   810                     System.err.println(
   811                         LocalizedMessage.getMessage(
   811                         LocalizedMessage.getNonlocalized(
   812                             POLICY + ".error.adding.Permission.perm.message",
   812                             POLICY + ".error.adding.Permission.perm.message",
   813                             source));
   813                             source));
   814                 } catch (Exception e) {
   814                 } catch (Exception e) {
   815                     Object[] source = {pe.permission,
   815                     Object[] source = {pe.permission,
   816                                        e.toString()};
   816                                        e.toString()};
   817                     System.err.println(
   817                     System.err.println(
   818                         LocalizedMessage.getMessage(
   818                         LocalizedMessage.getNonlocalized(
   819                             POLICY + ".error.adding.Permission.perm.message",
   819                             POLICY + ".error.adding.Permission.perm.message",
   820                             source));
   820                             source));
   821                 }
   821                 }
   822             }
   822             }
   823 
   823 
   824             // No need to sync because noone has access to newInfo yet
   824             // No need to sync because noone has access to newInfo yet
   825             newInfo.policyEntries.add(entry);
   825             newInfo.policyEntries.add(entry);
   826         } catch (Exception e) {
   826         } catch (Exception e) {
   827             Object[] source = {e.toString()};
   827             Object[] source = {e.toString()};
   828             System.err.println(
   828             System.err.println(
   829                 LocalizedMessage.getMessage(
   829                 LocalizedMessage.getNonlocalized(
   830                     POLICY + ".error.adding.Entry.message",
   830                     POLICY + ".error.adding.Entry.message",
   831                     source));
   831                     source));
   832         }
   832         }
   833         if (debug != null)
   833         if (debug != null)
   834             debug.println();
   834             debug.println();
  1801             } else if (prefix.equalsIgnoreCase("alias")) {
  1801             } else if (prefix.equalsIgnoreCase("alias")) {
  1802                 // get the suffix and perform keystore alias replacement
  1802                 // get the suffix and perform keystore alias replacement
  1803                 if (colonIndex == -1) {
  1803                 if (colonIndex == -1) {
  1804                     Object[] source = {pe.name};
  1804                     Object[] source = {pe.name};
  1805                     throw new Exception(
  1805                     throw new Exception(
  1806                         LocalizedMessage.getMessage(
  1806                         LocalizedMessage.getNonlocalized(
  1807                             "alias.name.not.provided.pe.name.",
  1807                             "alias.name.not.provided.pe.name.",
  1808                             source));
  1808                             source));
  1809                 }
  1809                 }
  1810                 suffix = value.substring(colonIndex+1);
  1810                 suffix = value.substring(colonIndex+1);
  1811                 if ((suffix = getDN(suffix, keystore)) == null) {
  1811                 if ((suffix = getDN(suffix, keystore)) == null) {
  1812                     Object[] source = {value.substring(colonIndex+1)};
  1812                     Object[] source = {value.substring(colonIndex+1)};
  1813                     throw new Exception(
  1813                     throw new Exception(
  1814                         LocalizedMessage.getMessage(
  1814                         LocalizedMessage.getNonlocalized(
  1815                             "unable.to.perform.substitution.on.alias.suffix",
  1815                             "unable.to.perform.substitution.on.alias.suffix",
  1816                             source));
  1816                             source));
  1817                 }
  1817                 }
  1818 
  1818 
  1819                 sb.append(X500PRINCIPAL + " \"" + suffix + "\"");
  1819                 sb.append(X500PRINCIPAL + " \"" + suffix + "\"");
  1820                 startIndex = e+2;
  1820                 startIndex = e+2;
  1821             } else {
  1821             } else {
  1822                 Object[] source = {prefix};
  1822                 Object[] source = {prefix};
  1823                 throw new Exception(
  1823                 throw new Exception(
  1824                     LocalizedMessage.getMessage(
  1824                     LocalizedMessage.getNonlocalized(
  1825                         "substitution.value.prefix.unsupported",
  1825                         "substitution.value.prefix.unsupported",
  1826                         source));
  1826                         source));
  1827             }
  1827             }
  1828         }
  1828         }
  1829 
  1829 
  2035                               Certificate[] certs)
  2035                               Certificate[] certs)
  2036         {
  2036         {
  2037             super(type);
  2037             super(type);
  2038             if (type == null) {
  2038             if (type == null) {
  2039                 throw new NullPointerException
  2039                 throw new NullPointerException
  2040                     (LocalizedMessage.getMessage("type.can.t.be.null"));
  2040                     (LocalizedMessage.getNonlocalized("type.can.t.be.null"));
  2041             }
  2041             }
  2042             this.type = type;
  2042             this.type = type;
  2043             this.name = name;
  2043             this.name = name;
  2044             this.actions = actions;
  2044             this.actions = actions;
  2045             if (certs != null) {
  2045             if (certs != null) {