sun.security.util.PropertyExpander Java Examples

The following examples show how to use sun.security.util.PropertyExpander. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProviderConfig.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #2
Source File: ConfigFile.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #3
Source File: KeyStoreUtil.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Parses a option line likes
 *    -genkaypair -dname "CN=Me"
 * and add the results into a list
 * @param list the list to fill into
 * @param s the line
 */
private static void parseArgsLine(List<String> list, String s)
        throws IOException, PropertyExpander.ExpandException {
    StreamTokenizer st = new StreamTokenizer(new StringReader(s));

    st.resetSyntax();
    st.whitespaceChars(0x00, 0x20);
    st.wordChars(0x21, 0xFF);
    // Everything is a word char except for quotation and apostrophe
    st.quoteChar('"');
    st.quoteChar('\'');

    while (true) {
        if (st.nextToken() == StreamTokenizer.TT_EOF) {
            break;
        }
        list.add(PropertyExpander.expand(st.sval));
    }
}
 
Example #4
Source File: ProviderConfig.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #5
Source File: PolicyParser.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #6
Source File: PolicyParser.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #7
Source File: ConfigFile.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.isEmpty()) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            linenum, value);
    }
    return s;
}
 
Example #8
Source File: PolicyParser.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #9
Source File: ProviderConfig.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #10
Source File: KeyStoreUtil.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a option line likes
 *    -genkaypair -dname "CN=Me"
 * and add the results into a list
 * @param list the list to fill into
 * @param s the line
 */
private static void parseArgsLine(List<String> list, String s)
        throws IOException, PropertyExpander.ExpandException {
    StreamTokenizer st = new StreamTokenizer(new StringReader(s));

    st.resetSyntax();
    st.whitespaceChars(0x00, 0x20);
    st.wordChars(0x21, 0xFF);
    // Everything is a word char except for quotation and apostrophe
    st.quoteChar('"');
    st.quoteChar('\'');

    while (true) {
        if (st.nextToken() == StreamTokenizer.TT_EOF) {
            break;
        }
        list.add(PropertyExpander.expand(st.sval));
    }
}
 
Example #11
Source File: PolicyParser.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #12
Source File: ProviderConfig.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #13
Source File: ProviderConfig.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #14
Source File: ConfigFile.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #15
Source File: PolicyParser.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #16
Source File: PolicyParser.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #17
Source File: ConfigFile.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #18
Source File: ProviderConfig.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #19
Source File: PolicyParser.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(), value);
    }

    return properties;
}
 
Example #20
Source File: ConfigFile.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #21
Source File: PolicyParser.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #22
Source File: PolicyParser.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #23
Source File: PolicyParser.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private Map<String, String> parseProperties(String terminator)
    throws ParsingException, IOException {

    Map<String, String> properties = new HashMap<>();
    String key;
    String value;
    while (!peek(terminator)) {
        key = match("property name");
        match("=");

        try {
            value = expand(match("quoted string"));
        } catch (PropertyExpander.ExpandException peee) {
            throw new IOException(peee.getLocalizedMessage());
        }
        properties.put(key.toLowerCase(Locale.ENGLISH), value);
    }

    return properties;
}
 
Example #24
Source File: ConfigFile.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #25
Source File: ProviderConfig.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #26
Source File: ProviderConfig.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform property expansion of the provider value.
 *
 * NOTE use of doPrivileged().
 */
private static String expand(final String value) {
    // shortcut if value does not contain any properties
    if (value.contains("${") == false) {
        return value;
    }
    return AccessController.doPrivileged(new PrivilegedAction<String>() {
        public String run() {
            try {
                return PropertyExpander.expand(value);
            } catch (GeneralSecurityException e) {
                throw new ProviderException(e);
            }
        }
    });
}
 
Example #27
Source File: ConfigFile.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private String expand(String value)
    throws PropertyExpander.ExpandException, IOException {

    if (value.isEmpty()) {
        return value;
    }

    if (!expandProp) {
        return value;
    }
    String s = PropertyExpander.expand(value);
    if (s == null || s.length() == 0) {
        throw ioException(
            "Configuration.Error.Line.line.system.property.value.expanded.to.empty.value",
            new Integer(linenum), value);
    }
    return s;
}
 
Example #28
Source File: Config.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static String expand(final String s) throws IOException {
    try {
        return PropertyExpander.expand(s);
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
    }
}
 
Example #29
Source File: KeyStoreUtil.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Prepends matched options from a pre-configured options file.
 *
 * @param tool the name of the tool, can be "keytool" or "jarsigner"
 * @param file the pre-configured options file
 * @param c1 the name of the command, with the "-" prefix,
 *        must not be null
 * @param c2 the alternative command name, with the "-" prefix,
 *        null if none. For example, "genkey" is alt name for
 *        "genkeypair". A command can only have one alt name now.
 * @param args existing arguments
 * @return arguments combined
 * @throws IOException if there is a file I/O or format error
 * @throws PropertyExpander.ExpandException
 *         if there is a property expansion error
 */
public static String[] expandArgs(String tool, String file,
                String c1, String c2, String[] args)
        throws IOException, PropertyExpander.ExpandException {

    List<String> result = new ArrayList<>();
    Properties p = new Properties();
    p.load(new FileInputStream(file));

    String s = p.getProperty(tool + ".all");
    if (s != null) {
        parseArgsLine(result, s);
    }

    // Cannot provide both -genkey and -genkeypair
    String s1 = p.getProperty(tool + "." + c1.substring(1));
    String s2 = null;
    if (c2 != null) {
        s2 = p.getProperty(tool + "." + c2.substring(1));
    }
    if (s1 != null && s2 != null) {
        throw new IOException("Cannot have both " + c1 + " and "
                + c2 + " as pre-configured options");
    }
    if (s1 == null) {
        s1 = s2;
    }
    if (s1 != null) {
        parseArgsLine(result, s1);
    }

    if (result.isEmpty()) {
        return args;
    } else {
        result.addAll(Arrays.asList(args));
        return result.toArray(new String[result.size()]);
    }
}
 
Example #30
Source File: PolicyParser.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public String getStorePassURL() {
    try {
        if (storePassURL!=null && storePassURL.length()!=0) {
            return expand(storePassURL, true).replace
                                            (File.separatorChar, '/');
        }
    } catch (PropertyExpander.ExpandException peee) {
        if (debug != null) {
            debug.println(peee.toString());
        }
        return null;
    }
    return null;
}