/*
 * 
 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * The contents of this file are subject to the Sun Community Source
 * License v3.0/Jini Technology Specific Attachment v 1.0 (the
 * "License"). You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at
 * http://wwws.sun.com/software/jini/licensing/SCSL3_JiniTSA1.html.
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 * the License for the specific language governing rights and limitations
 * under the License.
 * 
 * The Reference Code is Jini Technology Core Platform code, v2.0. The
 * Developer of the Reference Code is Sun Microsystems, Inc.
 * 
 * Contributor(s): Sun Microsystems, Inc.
 * 
 * The contents of this file comply with the Jini Technology Core
 * Platform Compatibility Kit, v2.0A.
 * 
 * Tester(s): Sun Microsystems, Inc.
 * 
 * Test Platform(s):
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Solaris(TM)SPARC/x86
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Linux (Intel x86)
 * Java 2 SDK, Standard Edition, Version 1.4.2_03 for Windows (Intel Platform)
 * 
 */

package net.jini.security.proxytrust;

import java.rmi.RemoteException;

/**
 * Defines an iterator that produces objects from which a
 * {@link net.jini.security.TrustVerifier} might be obtained.
 * {@link ProxyTrustVerifier} obtains such iterators from instances of
 * classes that have a non-<code>static</code> member method with signature:
 * <pre>ProxyTrustIterator getProxyTrustIterator();</pre>
 * The expectation is that each element produced by the iterator either
 * implements {@link ProxyTrust} or might have a
 * <code>getProxyTrustIterator</code> method that can be used recursively to
 * obtain further candidates.
 *
 * @author Sun Microsystems, Inc.
 * 
 * @since 2.0
 */
public interface ProxyTrustIterator {
    /**
     * Returns <code>true</code> if the iteration has more elements, and
     * <code>false</code> otherwise.
     *
     * @return <code>true</code> if the iteration has more elements, and
     * <code>false</code> otherwise
     */
    boolean hasNext();

    /**
     * Returns the next element in the iteration. This method can throw
     * an exception (other than <code>NoSuchElementException</code>) without
     * terminating the iteration.
     *
     * @return the next element in the iteration
     * @throws NoSuchElementException if the iteration has no more elements
     * @throws RemoteException if a communication-related exception occurs
     * while producing the next element
     * @throws RuntimeException if a runtime exception occurs while producing
     * the next element
     */
    Object next() throws RemoteException;

    /**
     * Provides the iteration with a <code>RemoteException</code> thrown from
     * a remote call made while attempting to obtain a
     * {@link net.jini.security.TrustVerifier} from the object
     * returned by the most recent call to {@link #next next}. Setting an
     * exception may influence which (if any) elements are subsequently
     * produced by the iteration. (A <code>RemoteException</code> thrown
     * directly by <code>next</code> should not be passed to this method.)
     *
     * @param e <code>RemoteException</code> thrown from a remote call
     * @throws NullPointerException if the argument is <code>null</code>
     * @throws IllegalStateException if <code>next</code> has never been
     * called, or if this method has already been called since the most
     * recent call to <code>next</code>, or if <code>hasNext</code> has been
     * called since the most recent call to <code>next</code>, or if the most
     * recent call to <code>next</code> threw a <code>RemoteException</code>
     */
    void setException(RemoteException e);
}
