Search in sources :

Example 26 with ListIterator

use of java.util.ListIterator in project jdk8u_jdk by JetBrains.

the class Remove method main.

public static void main(String[] args) {
    LinkedList list = new LinkedList();
    ListIterator e = list.listIterator();
    Object o = new Integer(1);
    e.add(o);
    e.previous();
    e.next();
    e.remove();
    e.add(o);
    if (!o.equals(list.get(0)))
        throw new RuntimeException("LinkedList ListIterator remove failed.");
}
Also used : ListIterator(java.util.ListIterator) LinkedList(java.util.LinkedList)

Example 27 with ListIterator

use of java.util.ListIterator in project OpenAM by OpenRock.

the class UpgradeUtils method replaceTags.

/**
     * Replace tags in the upgrade services xmls
     */
static void replaceTags(File dir, Properties p) {
    try {
        LinkedList fileList = new LinkedList();
        getFiles(dir, fileList);
        ListIterator srcIter = fileList.listIterator();
        while (srcIter.hasNext()) {
            File file = (File) srcIter.next();
            String fname = file.getAbsolutePath();
            if (fname.endsWith("xml") || fname.endsWith("ldif")) {
                replaceTag(fname, p);
            }
        }
    } catch (Exception e) {
    // do nothing
    }
}
Also used : ByteString(org.forgerock.opendj.ldap.ByteString) ListIterator(java.util.ListIterator) File(java.io.File) LinkedList(java.util.LinkedList) LoginException(javax.security.auth.login.LoginException) InvalidAuthContextException(com.sun.identity.authentication.internal.InvalidAuthContextException) UnknownPropertyNameException(com.sun.identity.common.configuration.UnknownPropertyNameException) PolicyException(com.sun.identity.policy.PolicyException) FileNotFoundException(java.io.FileNotFoundException) SSOException(com.iplanet.sso.SSOException) LdapException(org.forgerock.opendj.ldap.LdapException) SMSException(com.sun.identity.sm.SMSException) IOException(java.io.IOException) AMException(com.iplanet.am.sdk.AMException) ConfigurationException(com.sun.identity.common.configuration.ConfigurationException)

Example 28 with ListIterator

use of java.util.ListIterator in project OpenAM by OpenRock.

the class SPSingleLogout method prepareForLogout.

private static String prepareForLogout(String realm, String tokenID, String metaAlias, List extensionsList, String binding, String relayState, HttpServletRequest request, HttpServletResponse response, Map paramsMap, String infoKeyString, LogoutRequest origLogoutRequest, SOAPMessage msg) throws SAML2Exception, SessionException {
    NameIDInfoKey nameIdInfoKey = NameIDInfoKey.parse(infoKeyString);
    String sessionIndex = null;
    NameID nameID = null;
    if (SPCache.isFedlet) {
        sessionIndex = SAML2Utils.getParameter(paramsMap, SAML2Constants.SESSION_INDEX);
        nameID = AssertionFactory.getInstance().createNameID();
        nameID.setValue(nameIdInfoKey.getNameIDValue());
        nameID.setFormat(SAML2Constants.NAMEID_TRANSIENT_FORMAT);
        nameID.setNameQualifier(nameIdInfoKey.getRemoteEntityID());
        nameID.setSPNameQualifier(nameIdInfoKey.getHostEntityID());
    } else {
        SPFedSession fedSession = null;
        List list = (List) SPCache.fedSessionListsByNameIDInfoKey.get(infoKeyString);
        if (list != null) {
            synchronized (list) {
                ListIterator iter = list.listIterator();
                while (iter.hasNext()) {
                    fedSession = (SPFedSession) iter.next();
                    if (tokenID.equals(fedSession.spTokenID)) {
                        iter.remove();
                        if ((agent != null) && agent.isRunning() && (saml2Svc != null)) {
                            saml2Svc.setFedSessionCount((long) SPCache.fedSessionListsByNameIDInfoKey.size());
                        }
                        if (list.size() == 0) {
                            SPCache.fedSessionListsByNameIDInfoKey.remove(infoKeyString);
                        }
                        break;
                    }
                    fedSession = null;
                }
            }
        }
        if (fedSession == null) {
            // just do local logout
            if (debug.messageEnabled()) {
                debug.message("No session partner, just do local logout.");
            }
            return null;
        }
        sessionIndex = fedSession.idpSessionIndex;
        nameID = fedSession.info.getNameID();
    }
    // get IDPSSODescriptor
    IDPSSODescriptorElement idpsso = sm.getIDPSSODescriptor(realm, nameIdInfoKey.getRemoteEntityID());
    if (idpsso == null) {
        String[] data = { nameIdInfoKey.getRemoteEntityID() };
        LogUtil.error(Level.INFO, LogUtil.IDP_METADATA_ERROR, data, null);
        throw new SAML2Exception(SAML2Utils.bundle.getString("metaDataError"));
    }
    List slosList = idpsso.getSingleLogoutService();
    if (slosList == null) {
        String[] data = { nameIdInfoKey.getRemoteEntityID() };
        LogUtil.error(Level.INFO, LogUtil.SLO_NOT_FOUND, data, null);
        throw new SAML2Exception(SAML2Utils.bundle.getString("sloServiceListNotfound"));
    }
    // get IDP entity config in case of SOAP, for basic auth info
    IDPSSOConfigElement idpConfig = null;
    if (binding.equals(SAML2Constants.SOAP)) {
        idpConfig = sm.getIDPSSOConfig(realm, nameIdInfoKey.getRemoteEntityID());
    }
    StringBuffer requestID = LogoutUtil.doLogout(metaAlias, nameIdInfoKey.getRemoteEntityID(), slosList, extensionsList, binding, relayState, sessionIndex, nameID, request, response, paramsMap, idpConfig);
    String requestIDStr = requestID.toString();
    if (debug.messageEnabled()) {
        debug.message("\nSPSLO.requestIDStr = " + requestIDStr + "\nbinding = " + binding);
    }
    if ((requestIDStr != null) && (requestIDStr.length() != 0) && (binding.equals(SAML2Constants.HTTP_REDIRECT) || binding.equals(SAML2Constants.HTTP_POST)) && (origLogoutRequest != null)) {
        IDPCache.proxySPLogoutReqCache.put(requestIDStr, origLogoutRequest);
    } else if ((requestIDStr != null) && (requestIDStr.length() != 0) && binding.equals(SAML2Constants.SOAP) && (msg != null)) {
        IDPCache.SOAPMessageByLogoutRequestID.put(requestIDStr, msg);
    }
    return requestIDStr;
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) NameID(com.sun.identity.saml2.assertion.NameID) List(java.util.List) ArrayList(java.util.ArrayList) IDPSSOConfigElement(com.sun.identity.saml2.jaxb.entityconfig.IDPSSOConfigElement) ListIterator(java.util.ListIterator) NameIDInfoKey(com.sun.identity.saml2.common.NameIDInfoKey) IDPSSODescriptorElement(com.sun.identity.saml2.jaxb.metadata.IDPSSODescriptorElement)

Example 29 with ListIterator

use of java.util.ListIterator in project OpenAM by OpenRock.

the class RequestAbstractImpl method parseDOMElement.

/** 
     * Parses the Docuemnt Element for this object.
     * 
     * @param element the Document Element of this object.
     * @throws SAML2Exception if error parsing the Document Element.
     */
protected void parseDOMElement(Element element) throws SAML2Exception {
    parseDOMAttributes(element);
    List childElementList = new ArrayList();
    NodeList nList = element.getChildNodes();
    if ((nList != null) && (nList.getLength() > 0)) {
        for (int i = 0; i < nList.getLength(); i++) {
            Node childNode = nList.item(i);
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                childElementList.add(childNode);
            }
        }
    }
    ListIterator iter = childElementList.listIterator();
    parseDOMChileElements(iter);
    if (iter.hasNext()) {
        if (SAML2SDKUtils.debug.messageEnabled()) {
            SAML2SDKUtils.debug.message("RequestAbstractImpl." + "parseDOMElement: Unexpected child element found");
        }
        throw new SAML2Exception(SAML2SDKUtils.bundle.getString("schemaViolation"));
    }
}
Also used : SAML2Exception(com.sun.identity.saml2.common.SAML2Exception) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) ListIterator(java.util.ListIterator)

Example 30 with ListIterator

use of java.util.ListIterator in project smali by JesusFreke.

the class AbstractForwardSequentialList method listIterator.

@Override
@Nonnull
public ListIterator<T> listIterator(final int initialIndex) {
    final Iterator<T> initialIterator;
    try {
        initialIterator = iterator(initialIndex);
    } catch (NoSuchElementException ex) {
        throw new IndexOutOfBoundsException();
    }
    return new AbstractListIterator<T>() {

        private int index = initialIndex - 1;

        @Nullable
        private Iterator<T> forwardIterator = initialIterator;

        @Nonnull
        private Iterator<T> getForwardIterator() {
            if (forwardIterator == null) {
                try {
                    forwardIterator = iterator(index + 1);
                } catch (IndexOutOfBoundsException ex) {
                    throw new NoSuchElementException();
                }
            }
            return forwardIterator;
        }

        @Override
        public boolean hasNext() {
            return getForwardIterator().hasNext();
        }

        @Override
        public boolean hasPrevious() {
            return index >= 0;
        }

        @Override
        public T next() {
            T ret = getForwardIterator().next();
            index++;
            return ret;
        }

        @Override
        public int nextIndex() {
            return index + 1;
        }

        @Override
        public T previous() {
            forwardIterator = null;
            try {
                return iterator(index--).next();
            } catch (IndexOutOfBoundsException ex) {
                throw new NoSuchElementException();
            }
        }

        @Override
        public int previousIndex() {
            return index;
        }
    };
}
Also used : Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) NoSuchElementException(java.util.NoSuchElementException) Nonnull(javax.annotation.Nonnull)

Aggregations

ListIterator (java.util.ListIterator)81 List (java.util.List)30 ArrayList (java.util.ArrayList)29 LinkedList (java.util.LinkedList)26 Iterator (java.util.Iterator)15 AbstractList (java.util.AbstractList)7 AbstractSequentialList (java.util.AbstractSequentialList)6 RandomAccess (java.util.RandomAccess)5 SelectResults (org.apache.geode.cache.query.SelectResults)5 Test (org.junit.Test)5 Map (java.util.Map)4 NoSuchElementException (java.util.NoSuchElementException)4 SipURI (javax.sip.address.SipURI)4 StructTypeImpl (org.apache.geode.cache.query.internal.types.StructTypeImpl)4 File (java.io.File)3 IOException (java.io.IOException)3 SipException (javax.sip.SipException)3 ObjectType (org.apache.geode.cache.query.types.ObjectType)3 StructType (org.apache.geode.cache.query.types.StructType)3 SAML2Exception (com.sun.identity.saml2.common.SAML2Exception)2