/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.provider.certpath;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
* An AdjacencyList is used to store the history of certification paths
* attempted in constructing a path from an initiator to a target. The
* AdjacencyList is initialized with a List
of
* List
s, where each sub-List
contains objects of
* type Vertex
. A Vertex
describes one possible or
* actual step in the chain building process, and the associated
* Certificate
. Specifically, a Vertex
object
* contains a Certificate
and an index value referencing the
* next sub-list in the process. If the index value is -1 then this
* Vertex
doesn't continue the attempted build path.
*
* Example: *
* Attempted Paths:
* AdjacencyList structure:
* The iterator method returns objects of type BuildStep
, not
* objects of type Vertex
.
* A BuildStep
contains a Vertex
and a result code,
* accessible via getResult method. There are five result values.
* POSSIBLE
denotes that the current step represents a
* Certificate
that the builder is considering at this point in
* the build. FOLLOW
denotes a Certificate
(one of
* those noted as POSSIBLE
) that the builder is using to try
* extending the chain. BACK
represents that a
* FOLLOW
was incorrect, and is being removed from the chain.
* There is exactly one FOLLOW
for each BACK
. The
* values SUCCEED
and FAIL
mean that we've come to
* the end of the build process, and there will not be any more entries in
* the list.
*
* @see sun.security.provider.certpath.BuildStep * @see sun.security.provider.certpath.Vertex *
* @author seth proctor
* @since 1.4
*/
public class AdjacencyList {
// the actual set of steps the AdjacencyList represents
private ArrayList> mOrigList;
/**
* Constructs a new
AdjacencyList
based on the specified
* List
. See the example above.
*
* @param list a List
of List
s of
* Vertex
objects
*/
public AdjacencyList(List> list) {
mStepList = new ArrayList
Iterator
to iterate over the set of
* BuildStep
s in build-order. Any attempts to change
* the list through the remove method will fail.
*
* @return an Iterator
over the BuildStep
s
*/
public IteratorFollow
is the parent BuildStep
* that we followed to get here, and if it's null, it means that we're
* at the start.
*/
private boolean buildList(List> theList, int index,
BuildStep follow) {
// Each time this method is called, we're examining a new list
// from the global list. So, we have to start by getting the list
// that contains the set of Vertexes we're considering.
List