Package java.net

Examples of java.net.ProtocolException


                                        // Looks like the user has forgoton to resume the connection
                                        if (suspends == suspendChanges.get() && suspendCount.get() > 0) {
                                            handleFatalFailure(new IllegalStateException("The connection has remained suspended for an extended period of time so it cannot do proper keep alive processing.  Did you forget to resume the connection?"));
                                        } else {
                                            mqtt.tracer.debug("Ping timeout");
                                            handleSessionFailure(new ProtocolException("Ping timeout").fillInStackTrace());
                                        }
                                    }
                                }
                            });
                        }
View Full Code Here


                } else {
                    ((Callback<Object>)request.cb).onSuccess(arg);
                }
            }
        } else {
            handleFatalFailure(new ProtocolException("Command from server contained an invalid message id: " + id));
        }
    }
View Full Code Here

                case PINGRESP.TYPE: {
                    pingedAt = 0;
                    break;
                }
                default:
                    throw new ProtocolException("Unexpected MQTT command type: "+frame.messageType());
            }
        } catch (Throwable e) {
            handleFatalFailure(e);
        }
    }
View Full Code Here

        assert(frame.buffers.length == 1);
        DataByteArrayInputStream is = new DataByteArrayInputStream(frame.buffers[0]);
        is.skip(1);
        byte c = is.readByte();
        if( c >= Code.values().length ) {
            throw new ProtocolException("Invalid CONNACK encoding");
        }
        code = Code.values()[c];
        return this;
    }
View Full Code Here

                        conn.receiveResponseEntity(response);
                    }
                    int status = response.getStatusLine().getStatusCode();
                    if (status < 200) {
                        if (status != HttpStatus.SC_CONTINUE) {
                            throw new ProtocolException(
                                    "Unexpected response: " + response.getStatusLine());
                        }
                        // discard 100-continue
                        response = null;
                    } else {
View Full Code Here

    static protected UTF8Buffer readUTF(DataByteArrayInputStream is) throws ProtocolException {
        int size = is.readShort();
        Buffer buffer = is.readBuffer(size);
        if (buffer == null || buffer.length != size) {
            throw new ProtocolException("Invalid message encoding");
        }
        return buffer.utf8();
    }
View Full Code Here

    */
   @Override
   public void setRequestMethod(String method) throws ProtocolException
   {
      if (connected)
         throw new ProtocolException("Already connected!");

      if (log.isDebugEnabled())
         log.debug(urlString + " Setting request method: " + method);

      this.method = method.trim().toUpperCase();
View Full Code Here

    */
   @Override
   public InputStream getInputStream() throws IOException
   {
      if (!doInput)
         throw new ProtocolException("Input not enabled! (use setDoInput(true))");

      if (!connected)
         connect();

      InputStream stream;
View Full Code Here

    */
   @Override
   public synchronized OutputStream getOutputStream() throws IOException
   {
      if (connected)
         throw new ProtocolException("Already connected!");

      if (!doOutput)
         throw new ProtocolException("Output not enabled! (use setDoOutput(true))");
      if (!method_set)
         method = "POST";
      else if (method.equals("HEAD") || method.equals("GET") || method.equals("TRACE"))
         throw new ProtocolException("Method " + method + " does not support output!");

      if (getRequestProperty("Content-type") == null)
         setRequestProperty("Content-type", "application/x-www-form-urlencoded");

      if (output_stream == null)
View Full Code Here

        String algorithm = params.getAlgorithm ();
        int  nccount = params.getNCCount ();
        String ncstring=null;

        if (header == null) {
            throw new ProtocolException ("No authentication information in response");
        }

        if (nccount != -1) {
            ncstring = Integer.toHexString (nccount).toUpperCase();
            int len = ncstring.length();
            if (len < 8)
                ncstring = zeroPad [len] + ncstring;
        }
        try {
            String expected = computeDigest(false, username,passwd,realm,
                                        method, uri, nonce, cnonce, ncstring);
            HeaderParser p = new HeaderParser (header);
            String rspauth = p.findValue ("rspauth");
            if (rspauth == null) {
                throw new ProtocolException ("No digest in response");
            }
            if (!rspauth.equals (expected)) {
                throw new ProtocolException ("Response digest invalid");
            }
            /* Check if there is a nextnonce field */
            String nextnonce = p.findValue ("nextnonce");
            if (nextnonce != null && ! "".equals(nextnonce)) {
                params.setNonce (nextnonce);
            }

        } catch (NoSuchAlgorithmException ex) {
            throw new ProtocolException ("Unsupported algorithm in response");
        }
    }
View Full Code Here

TOP

Related Classes of java.net.ProtocolException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.