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);
}
}
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;
}
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();
}
}
}
}
}
}
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);
}
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.");
}
Aggregations