passwordDetails details)
{
}
});
final SESecurityManager sec_man = plugin_interface.getUtilities().getSecurityManager();
final SEPublicKey my_key = sec_man.getPublicKey( SEPublicKey.KEY_TYPE_ECC_192, "test" );
final int stream_crypto = MessageManager.STREAM_ENCRYPTION_RC4_REQUIRED;
final boolean use_sts = true;
final int block_crypto = SESecurityManager.BLOCK_ENCRYPTION_AES;
GenericMessageRegistration reg =
plugin_interface.getMessageManager().registerGenericMessageType(
"GENTEST", "Gen test desc",
stream_crypto,
new GenericMessageHandler()
{
public boolean
accept(
GenericMessageConnection connection )
throws MessageException
{
System.out.println( "accept" );
try{
if ( use_sts ){
connection = sec_man.getSTSConnection(
connection,
my_key,
new SEPublicKeyLocator()
{
public boolean
accept(
Object context,
SEPublicKey other_key )
{
System.out.println( "acceptKey" );
return( true );
}
},
"test",
block_crypto );
}
connection.addListener(
new GenericMessageConnectionListener()
{
public void
connected(
GenericMessageConnection connection )
{
}
public void
receive(
GenericMessageConnection connection,
PooledByteBuffer message )
throws MessageException
{
System.out.println( "receive: " + message.toByteArray().length );
PooledByteBuffer reply =
plugin_interface.getUtilities().allocatePooledByteBuffer(
new byte[connection.getMaximumMessageSize()]);
connection.send( reply );
}
public void
failed(
GenericMessageConnection connection,
Throwable error )
throws MessageException
{
System.out.println( "Responder connection error:" );
error.printStackTrace();
}
});
}catch( Throwable e ){
connection.close();
e.printStackTrace();
}
return( true );
}
});
InetSocketAddress tcp_target = new InetSocketAddress( "127.0.0.1", 6889 );
InetSocketAddress udp_target = new InetSocketAddress( "212.159.18.92", 6881 );
GenericMessageEndpoint endpoint = reg.createEndpoint( tcp_target );
endpoint.addTCP( tcp_target );
endpoint.addUDP( udp_target );
while( true ){
try{
for (int i=0;i<1000;i++){
System.out.println( "Test: initiating connection" );
final AESemaphore sem = new AESemaphore( "wait!" );
GenericMessageConnection con = reg.createConnection( endpoint );
if ( use_sts ){
con = sec_man.getSTSConnection(
con, my_key,
new SEPublicKeyLocator()
{
public boolean
accept(