sun.security.x509.NameConstraintsExtension Java Examples

The following examples show how to use sun.security.x509.NameConstraintsExtension. 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: ReverseState.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #2
Source File: ReverseState.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #3
Source File: ReverseState.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #4
Source File: ReverseState.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #5
Source File: ReverseState.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #6
Source File: ReverseState.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
public Object clone() {
    try {
        ReverseState clonedState = (ReverseState) super.clone();

        /* clone checkers, if cloneable */
        clonedState.userCheckers =
                    (ArrayList<PKIXCertPathChecker>)userCheckers.clone();
        ListIterator<PKIXCertPathChecker> li =
                    clonedState.userCheckers.listIterator();
        while (li.hasNext()) {
            PKIXCertPathChecker checker = li.next();
            if (checker instanceof Cloneable) {
                li.set((PKIXCertPathChecker)checker.clone());
            }
        }

        /* make copy of name constraints */
        if (nc != null) {
            clonedState.nc = (NameConstraintsExtension) nc.clone();
        }

        /* make copy of policy tree */
        if (rootNode != null) {
            clonedState.rootNode = rootNode.copyTree();
        }

        return clonedState;
    } catch (CloneNotSupportedException e) {
        throw new InternalError(e.toString(), e);
    }
}
 
Example #7
Source File: ConstraintsChecker.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #8
Source File: ConstraintsChecker.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #9
Source File: ConstraintsChecker.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #10
Source File: ConstraintsChecker.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #11
Source File: ConstraintsChecker.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #12
Source File: ConstraintsChecker.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC);
        debug.println("newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #13
Source File: ConstraintsChecker.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC);
        debug.println("newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #14
Source File: ConstraintsChecker.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #15
Source File: ConstraintsChecker.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #16
Source File: ConstraintsChecker.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #17
Source File: ConstraintsChecker.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #18
Source File: ConstraintsChecker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #19
Source File: ConstraintsChecker.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #20
Source File: ConstraintsChecker.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}
 
Example #21
Source File: ConstraintsChecker.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Helper to fold sets of name constraints together
 */
static NameConstraintsExtension mergeNameConstraints(
    X509Certificate currCert, NameConstraintsExtension prevNC)
    throws CertPathValidatorException
{
    X509CertImpl currCertImpl;
    try {
        currCertImpl = X509CertImpl.toImpl(currCert);
    } catch (CertificateException ce) {
        throw new CertPathValidatorException(ce);
    }

    NameConstraintsExtension newConstraints =
        currCertImpl.getNameConstraintsExtension();

    if (debug != null) {
        debug.println("prevNC = " + prevNC +
                    ", newNC = " + String.valueOf(newConstraints));
    }

    // if there are no previous name constraints, we just return the
    // new name constraints.
    if (prevNC == null) {
        if (debug != null) {
            debug.println("mergedNC = " + String.valueOf(newConstraints));
        }
        if (newConstraints == null) {
            return newConstraints;
        } else {
            // Make sure we do a clone here, because we're probably
            // going to modify this object later and we don't want to
            // be sharing it with a Certificate object!
            return (NameConstraintsExtension)newConstraints.clone();
        }
    } else {
        try {
            // after merge, prevNC should contain the merged constraints
            prevNC.merge(newConstraints);
        } catch (IOException ioe) {
            throw new CertPathValidatorException(ioe);
        }
        if (debug != null) {
            debug.println("mergedNC = " + prevNC);
        }
        return prevNC;
    }
}