Package org.gudy.azureus2.plugins.messaging

Examples of org.gudy.azureus2.plugins.messaging.MessageException


 
    throws MessageException
  {
    if ( !connected ){
     
      throw( new MessageException( "not connected" ));
   
   
    if ( !closed ){
 
      closed  = true;
View Full Code Here


       
        connection.connect( buffer );
       
      }catch( CryptoManagerException  e ){
       
        throw( new MessageException( "Failed to get initial keys", e ));
      }
    }
  }
View Full Code Here

           
            if ( !key_locator.accept(
                SESTSConnectionImpl.this,
                new SEPublicKeyImpl( my_public_key.getType(), rem_key ))){
             
              throw( new MessageException( "remote public key not accepted" ));
            }
             
            setupBlockCrypto();
           
            if ( pending_message != null ){
             
              byte[]  pending_bytes = pending_message.toByteArray();
             
              int  pending_size = pending_bytes.length;
             
              if ( outgoing_cipher != null ){
               
                pending_size =  (( pending_size + AES_KEY_SIZE_BYTES -1 )/AES_KEY_SIZE_BYTES)*AES_KEY_SIZE_BYTES;
               
                if ( pending_size == 0 ){
                 
                  pending_size = AES_KEY_SIZE_BYTES;
                }
              }
             
              if ( out_buffer.remaining() >= pending_size ){
               
                if ( outgoing_cipher != null ){
                 
                 
                  out_buffer.put( outgoing_cipher.doFinal( pending_bytes ));
                 
                }else{
               
                  out_buffer.put( pending_bytes );
                }
               
                  // don't deallocate the pending message, the original caller does this
                               
                pending_message  = null;
              }
            }
           
            crypto_completed  = true;
           
          }else{
              // we've received
              //    a -> autb + data -> b
           
              // read their auth
           
            sts_engine.putAuth( in_buffer );

              // check we wanna talk to this person
           
            byte[]  rem_key = sts_engine.getRemotePublicKey();
           
            if ( !key_locator.accept(
                SESTSConnectionImpl.this,
                new SEPublicKeyImpl( my_public_key.getType(), rem_key ))){
             
                // this is just here to prevent unwanted spew  during closedown process
             
              connection.closing();
             
              throw( new MessageException( "remote public key not accepted" ));
            }
           
            setupBlockCrypto();

            crypto_completed  = true;
           
              // pick up any remaining data for delivery
           
            if ( in_buffer.hasRemaining()){
             
              message = new PooledByteBufferImpl( new DirectByteBuffer( in_buffer.slice()));
             
              forward  = true;
            }
          }
        }
      }
       
      if ( out_buffer != null ){
       
        out_buffer.flip();
       
        connection.send( new PooledByteBufferImpl( new DirectByteBuffer( out_buffer )));
      }
     
      if ( crypto_completed ){
       
        cryptoComplete();
      }
      if ( forward ){
       
        receiveContent( message );
      }
    }catch( Throwable e ){
     
      reportFailed( e );
     
      if ( e instanceof MessageException ){
       
        throw((MessageException)e);
       
      }else{
       
        throw( new MessageException( "Receive failed", e ));
      }
    }
  }
View Full Code Here

              outgoing_cipher  = cipher2;
          }

      }catch( Throwable e ){
       
        throw( new MessageException( "Failed to setup block encryption", e ));
      }
    }
  }
View Full Code Here

 
    throws MessageException
  {
    if ( failed ){
     
      throw( new MessageException( "Connection failed" ));
    }
   
    try{
      if ( crypto_complete.isReleasedForever()){
       
        sendContent( message );
       
      }else{
       
          // not complete, stash the message so it has a chance of being piggybacked on
          // the crypto protocol exchange
       
        synchronized( this ){
         
          if ( pending_message == null ){
           
            pending_message = message;
          }
        }
      }
     
      crypto_complete.reserve();
           
        // if the pending message couldn't be piggy backed it'll still be allocated
       
      boolean  send_it = false;
       
      synchronized( this ){

        if ( pending_message == message ){
         
          pending_message  = null;
         
          send_it  = true;
        }
      }
     
      if ( send_it ){
       
        sendContent( message );
      }

    }catch( Throwable e ){
     
      setFailed();
     
      if ( e instanceof MessageException ){
       
        throw((MessageException)e);
       
      }else{
       
        throw( new MessageException( "Send failed", e ));
      }
    }
  }
View Full Code Here

          throw( e );
        }
       
      }catch( Throwable e ){
       
        throw( new MessageException( "Failed to encrypt data", e ));
      }
    }else{
        // sanity check - never allow unencrypted outbound if block enc selected
     
      if ( block_crypto != SESecurityManager.BLOCK_ENCRYPTION_NONE ){
       
        connection.close();
       
        throw( new MessageException( "Crypto isn't setup" ));
      }
   
      connection.send( message );
    }
  }
View Full Code Here

         
          message  = temp;
         
        }catch( Throwable e ){
         
          throw( new MessageException( "Failed to decrypt data", e ));
        }
       
      }else if ( block_crypto != SESecurityManager.BLOCK_ENCRYPTION_NONE ){
       
        throw( new MessageException( "Crypto isn't setup" ));
      }
     
      List listeners_ref = listeners.getList();
     
      MessageException  last_error = null;
     
      for (int i=0;i<listeners_ref.size();i++){
       
        PooledByteBuffer  message_to_deliver;
       
        if ( i == 0 ){
         
          message_to_deliver  = message;
         
        }else{
       
            // unlikely we'll ever have > 1 receiver....
         
          message_to_deliver = new PooledByteBufferImpl( message.toByteArray());
        }
       
        try{
          ((GenericMessageConnectionListener)listeners_ref.get(i)).receive( this, message_to_deliver );
         
          if ( message_to_deliver == message ){
           
            buffer_handled  = true;
          }
        }catch( Throwable e ){
         
          message_to_deliver.returnToPool();
         
          if ( message_to_deliver == message ){

            buffer_handled  = true;
          }
         
          if ( e instanceof MessageException ){
         
            last_error = (MessageException)e;
           
          }else{
           
            last_error = new MessageException( "Failed to process message", e );
          }
        }
      }
     
      if ( last_error != null ){
View Full Code Here

          // while in unauth state we only allow a few messages. max should be 1
          // for an 'accept request' but I feel generous
       
        if ( recv_count >= 4 && !isAuthorised()){
       
          throw( new MessageException( "Too many messages received while in unauthorised state" ));
        }
       
        byte[]  content = message.toByteArray();
       
        Map  data_map = BDecoder.decode( content );
View Full Code Here

          public MessageStreamEncoder createEncoder() {  return new GenericMessageEncoder();}
          public MessageStreamDecoder createDecoder() {  return new GenericMessageDecoder(type, description);}
        });
   
  return(
    new GenericMessageRegistration()
    {
      public GenericMessageEndpoint
      createEndpoint(
        InetSocketAddress  notional_target )
      {
View Full Code Here

    }
    else {
      plug_msg = new MessageAdapter( message )//core created
    }
   
    RawMessage raw_plug = plug_encoder.encodeMessage( plug_msg );
    return new com.aelitis.azureus.core.networkmanager.RawMessage[]{ new RawMessageAdapter( raw_plug )};
  }
View Full Code Here

TOP

Related Classes of org.gudy.azureus2.plugins.messaging.MessageException

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.