Search in sources :

Example 21 with ListIterator

use of java.util.ListIterator in project XobotOS by xamarin.

the class PKIXCertPath method getEncoded.

/**
     * Returns the encoded form of this certification path, using
     * the specified encoding.
     *
     * @param encoding the name of the encoding to use
     * @return the encoded bytes
     * @exception CertificateEncodingException if an encoding error
     * occurs or the encoding requested is not supported
     *
     **/
public byte[] getEncoded(String encoding) throws CertificateEncodingException {
    if (encoding.equalsIgnoreCase("PkiPath")) {
        ASN1EncodableVector v = new ASN1EncodableVector();
        ListIterator iter = certificates.listIterator(certificates.size());
        while (iter.hasPrevious()) {
            v.add(toASN1Object((X509Certificate) iter.previous()));
        }
        return toDEREncoded(new DERSequence(v));
    } else if (encoding.equalsIgnoreCase("PKCS7")) {
        ContentInfo encInfo = new ContentInfo(PKCSObjectIdentifiers.data, null);
        ASN1EncodableVector v = new ASN1EncodableVector();
        for (int i = 0; i != certificates.size(); i++) {
            v.add(toASN1Object((X509Certificate) certificates.get(i)));
        }
        SignedData sd = new SignedData(new DERInteger(1), new DERSet(), encInfo, new DERSet(v), null, new DERSet());
        return toDEREncoded(new ContentInfo(PKCSObjectIdentifiers.signedData, sd));
    } else // BEGIN android-removed
    // else if (encoding.equalsIgnoreCase("PEM"))
    // {
    //     ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    //     PEMWriter             pWrt = new PEMWriter(new OutputStreamWriter(bOut));
    //
    //     try
    //     {
    //         for (int i = 0; i != certificates.size(); i++)
    //         {
    //             pWrt.writeObject(certificates.get(i));
    //         }
    //     
    //         pWrt.close();
    //     }
    //     catch (Exception e)
    //     {
    //         throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
    //     }
    //
    //     return bOut.toByteArray();
    // }
    // END android-removed
    {
        throw new CertificateEncodingException("unsupported encoding: " + encoding);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) SignedData(org.bouncycastle.asn1.pkcs.SignedData) ContentInfo(org.bouncycastle.asn1.pkcs.ContentInfo) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) CertificateEncodingException(java.security.cert.CertificateEncodingException) ListIterator(java.util.ListIterator) DERSet(org.bouncycastle.asn1.DERSet) X509Certificate(java.security.cert.X509Certificate) DERInteger(org.bouncycastle.asn1.DERInteger)

Example 22 with ListIterator

use of java.util.ListIterator in project XobotOS by xamarin.

the class SIPDialog method getRouteList.

/**
     * Get a cloned copy of route list for the Dialog.
     * 
     * @return -- a cloned copy of the dialog route list.
     */
private synchronized RouteList getRouteList() {
    if (sipStack.isLoggingEnabled())
        sipStack.getStackLogger().logDebug("getRouteList " + this);
    // Find the top via in the route list.
    ListIterator li;
    RouteList retval = new RouteList();
    retval = new RouteList();
    if (this.routeList != null) {
        li = routeList.listIterator();
        while (li.hasNext()) {
            Route route = (Route) li.next();
            retval.add((Route) route.clone());
        }
    }
    if (sipStack.isLoggingEnabled()) {
        sipStack.getStackLogger().logDebug("----- ");
        sipStack.getStackLogger().logDebug("getRouteList for " + this);
        if (retval != null)
            sipStack.getStackLogger().logDebug("RouteList = " + retval.encode());
        if (routeList != null)
            sipStack.getStackLogger().logDebug("myRouteList = " + routeList.encode());
        sipStack.getStackLogger().logDebug("----- ");
    }
    return retval;
}
Also used : RouteList(gov.nist.javax.sip.header.RouteList) RecordRouteList(gov.nist.javax.sip.header.RecordRouteList) ListIterator(java.util.ListIterator) RecordRoute(gov.nist.javax.sip.header.RecordRoute) Route(gov.nist.javax.sip.header.Route)

Example 23 with ListIterator

use of java.util.ListIterator in project XobotOS by xamarin.

the class SIPDialog method addRoute.

/**
     * Add a route list extracted from a record route list. If this is a server dialog then we
     * assume that the record are added to the route list IN order. If this is a client dialog
     * then we assume that the record route headers give us the route list to add in reverse
     * order.
     * 
     * @param recordRouteList -- the record route list from the incoming message.
     */
private void addRoute(RecordRouteList recordRouteList) {
    try {
        if (this.isClientDialog()) {
            // This is a client dialog so we extract the record
            // route from the response and reverse its order to
            // careate a route list.
            this.routeList = new RouteList();
            // start at the end of the list and walk backwards
            ListIterator li = recordRouteList.listIterator(recordRouteList.size());
            boolean addRoute = true;
            while (li.hasPrevious()) {
                RecordRoute rr = (RecordRoute) li.previous();
                if (addRoute) {
                    Route route = new Route();
                    AddressImpl address = ((AddressImpl) ((AddressImpl) rr.getAddress()).clone());
                    route.setAddress(address);
                    route.setParameters((NameValueList) rr.getParameters().clone());
                    this.routeList.add(route);
                }
            }
        } else {
            // This is a server dialog. The top most record route
            // header is the one that is closest to us. We extract the
            // route list in the same order as the addresses in the
            // incoming request.
            this.routeList = new RouteList();
            ListIterator li = recordRouteList.listIterator();
            boolean addRoute = true;
            while (li.hasNext()) {
                RecordRoute rr = (RecordRoute) li.next();
                if (addRoute) {
                    Route route = new Route();
                    AddressImpl address = ((AddressImpl) ((AddressImpl) rr.getAddress()).clone());
                    route.setAddress(address);
                    route.setParameters((NameValueList) rr.getParameters().clone());
                    routeList.add(route);
                }
            }
        }
    } finally {
        if (sipStack.getStackLogger().isLoggingEnabled()) {
            Iterator it = routeList.iterator();
            while (it.hasNext()) {
                SipURI sipUri = (SipURI) (((Route) it.next()).getAddress().getURI());
                if (!sipUri.hasLrParam()) {
                    if (sipStack.isLoggingEnabled()) {
                        sipStack.getStackLogger().logWarning("NON LR route in Route set detected for dialog : " + this);
                        sipStack.getStackLogger().logStackTrace();
                    }
                }
            }
        }
    }
}
Also used : ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) AddressImpl(gov.nist.javax.sip.address.AddressImpl) RouteList(gov.nist.javax.sip.header.RouteList) RecordRouteList(gov.nist.javax.sip.header.RecordRouteList) ListIterator(java.util.ListIterator) SipURI(javax.sip.address.SipURI) RecordRoute(gov.nist.javax.sip.header.RecordRoute) Route(gov.nist.javax.sip.header.Route) RecordRoute(gov.nist.javax.sip.header.RecordRoute)

Example 24 with ListIterator

use of java.util.ListIterator in project XobotOS by xamarin.

the class SIPDialog method sendReliableProvisionalResponse.

/*
     * (non-Javadoc)
     * 
     * @see javax.sip.Dialog#sendReliableProvisionalResponse(javax.sip.message.Response)
     */
public void sendReliableProvisionalResponse(Response relResponse) throws SipException {
    if (!this.isServer()) {
        throw new SipException("Not a Server Dialog");
    }
    SIPResponse sipResponse = (SIPResponse) relResponse;
    if (relResponse.getStatusCode() == 100)
        throw new SipException("Cannot send 100 as a reliable provisional response");
    if (relResponse.getStatusCode() / 100 > 2)
        throw new SipException("Response code is not a 1xx response - should be in the range 101 to 199 ");
    /*
         * Do a little checking on the outgoing response.
         */
    if (sipResponse.getToTag() == null) {
        throw new SipException("Badly formatted response -- To tag mandatory for Reliable Provisional Response");
    }
    ListIterator requireList = (ListIterator) relResponse.getHeaders(RequireHeader.NAME);
    boolean found = false;
    if (requireList != null) {
        while (requireList.hasNext() && !found) {
            RequireHeader rh = (RequireHeader) requireList.next();
            if (rh.getOptionTag().equalsIgnoreCase("100rel")) {
                found = true;
            }
        }
    }
    if (!found) {
        Require require = new Require("100rel");
        relResponse.addHeader(require);
        if (sipStack.isLoggingEnabled()) {
            sipStack.getStackLogger().logDebug("Require header with optionTag 100rel is needed -- adding one");
        }
    }
    SIPServerTransaction serverTransaction = (SIPServerTransaction) this.getFirstTransaction();
    /*
         * put into the dialog table before sending the response so as to avoid race condition
         * with PRACK
         */
    this.setLastResponse(serverTransaction, sipResponse);
    this.setDialogId(sipResponse.getDialogId(true));
    serverTransaction.sendReliableProvisionalResponse(relResponse);
    this.startRetransmitTimer(serverTransaction, relResponse);
}
Also used : SIPResponse(gov.nist.javax.sip.message.SIPResponse) Require(gov.nist.javax.sip.header.Require) RequireHeader(javax.sip.header.RequireHeader) SipException(javax.sip.SipException) ListIterator(java.util.ListIterator)

Example 25 with ListIterator

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

the class ComodifiedRemove method main.

public static void main(String[] args) {
    List list = new LinkedList();
    Object o1 = new Integer(1);
    list.add(o1);
    ListIterator e = list.listIterator();
    e.next();
    Object o2 = new Integer(2);
    list.add(o2);
    try {
        e.remove();
    } catch (ConcurrentModificationException cme) {
        return;
    }
    throw new RuntimeException("LinkedList ListIterator.remove() comodification check failed.");
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) ListIterator(java.util.ListIterator)

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