com.sun.jarsigner.ContentSigner Java Examples

The following examples show how to use com.sun.jarsigner.ContentSigner. 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: Main.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #2
Source File: Main.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #3
Source File: Main.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #4
Source File: Main.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #5
Source File: Main.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #6
Source File: Main.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #7
Source File: Main.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #8
Source File: Main.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #9
Source File: Main.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #10
Source File: JarSigner.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public byte[] generateBlock(ContentSignerParameters params,
                            boolean externalSF,
                            ContentSigner signingMechanism)
        throws NoSuchAlgorithmException,
               IOException, CertificateException {

    if (signingMechanism == null) {
        signingMechanism = new TimestampedSigner();
    }
    return signingMechanism.generateSignedData(
            params,
            externalSF,
            params.getTimestampingAuthority() != null
                || params.getTimestampingAuthorityCertificate() != null);
}
 
Example #11
Source File: Main.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #12
Source File: Main.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #13
Source File: Main.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private ContentSigner loadSigningMechanism(String signerClassName,
    String signerClassPath) throws Exception {

    // construct class loader
    String cpString = null;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(System.getProperty("env.class.path"), cpString);
    cpString = PathList.appendPath(System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    // attempt to find signer
    Class<?> signerClass = appClassLoader.loadClass(signerClassName);

    // Check that it implements ContentSigner
    Object signer = signerClass.newInstance();
    if (!(signer instanceof ContentSigner)) {
        MessageFormat form = new MessageFormat(
            rb.getString("signerClass.is.not.a.signing.mechanism"));
        Object[] source = {signerClass.getName()};
        throw new IllegalArgumentException(form.format(source));
    }
    return (ContentSigner)signer;
}
 
Example #14
Source File: Main.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #15
Source File: Main.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, signingMechanism, args, zipFile);
}
 
Example #16
Source File: Main.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #17
Source File: Main.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, signingMechanism, args, zipFile);
}
 
Example #18
Source File: Main.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, signingMechanism, args, zipFile);
}
 
Example #19
Source File: Main.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, signingMechanism, args, zipFile);
}
 
Example #20
Source File: Main.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #21
Source File: JarSigner.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
private ContentSigner loadSigningMechanism(String signerClassName,
                                           String signerClassPath) {

    // construct class loader
    String cpString;   // make sure env.class.path defaults to dot

    // do prepends to get correct ordering
    cpString = PathList.appendPath(
            System.getProperty("env.class.path"), null);
    cpString = PathList.appendPath(
            System.getProperty("java.class.path"), cpString);
    cpString = PathList.appendPath(signerClassPath, cpString);
    URL[] urls = PathList.pathToURLs(cpString);
    ClassLoader appClassLoader = new URLClassLoader(urls);

    try {
        // attempt to find signer
        Class<?> signerClass = appClassLoader.loadClass(signerClassName);
        Object signer = signerClass.newInstance();
        return (ContentSigner) signer;
    } catch (ClassNotFoundException|InstantiationException|
            IllegalAccessException|ClassCastException e) {
        throw new IllegalArgumentException(
                "Invalid altSigner or altSignerPath", e);
    }
}
 
Example #22
Source File: Main.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #23
Source File: Main.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #24
Source File: Main.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, signingMechanism, args, zipFile);
}
 
Example #25
Source File: Main.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}
 
Example #26
Source File: Main.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Block generateBlock(PrivateKey privateKey,
                           String sigalg,
                           X509Certificate[] certChain,
                           boolean externalSF, String tsaUrl,
                           X509Certificate tsaCert,
                           String tSAPolicyID,
                           String tSADigestAlg,
                           ContentSigner signingMechanism,
                           String[] args, ZipFile zipFile)
    throws NoSuchAlgorithmException, InvalidKeyException, IOException,
        SignatureException, CertificateException
{
    return new Block(this, privateKey, sigalg, certChain, externalSF,
            tsaUrl, tsaCert, tSAPolicyID, tSADigestAlg, signingMechanism, args, zipFile);
}