Beispiel #1
0
  /**
   * Returns the path length constraint. The shortest length in the chain of certificates is
   * returned as the credential's path length.
   *
   * @return The path length constraint of the credential. -1 is any error occurs.
   */
  public int getPathConstraint() {

    int pathLength = Integer.MAX_VALUE;
    try {
      for (int i = 0; i < this.certChain.length; i++) {
        int length = BouncyCastleUtil.getProxyPathConstraint(this.certChain[i]);
        // if length is one, then no proxy cert extension exists, so
        // path length is -1
        if (length == -1) {
          length = Integer.MAX_VALUE;
        }
        if (length < pathLength) {
          pathLength = length;
        }
      }
    } catch (Exception e) {
      logger.warn("Error retrieving path length.", e);
      pathLength = -1;
    }
    return pathLength;
  }