Java Code Examples for org.apache.catalina.tribes.ChannelMessage#getMessage()

The following examples show how to use org.apache.catalina.tribes.ChannelMessage#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EncryptInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
        throws ChannelException {
    try {
        byte[] data = msg.getMessage().getBytes();

        // See #encrypt(byte[]) for an explanation of the return value
        byte[][] bytes = encryptionManager.encrypt(data);

        XByteBuffer xbb = msg.getMessage();

        // Completely replace the message
        xbb.clear();
        xbb.append(bytes[0], 0, bytes[0].length);
        xbb.append(bytes[1], 0, bytes[1].length);

        super.sendMessage(destination, msg, payload);

    } catch (GeneralSecurityException gse) {
        log.error(sm.getString("encryptInterceptor.encrypt.failed"));
        throw new ChannelException(gse);
    }
}
 
Example 2
Source File: EncryptInterceptor.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    try {
        byte[] data = msg.getMessage().getBytes();

        data = encryptionManager.decrypt(data);

        XByteBuffer xbb = msg.getMessage();

        // Completely replace the message with the decrypted one
        xbb.clear();
        xbb.append(data, 0, data.length);

        super.messageReceived(msg);
    } catch (GeneralSecurityException gse) {
        log.error(sm.getString("encryptInterceptor.decrypt.failed"), gse);
    }
}
 
Example 3
Source File: NonBlockingCoordinator.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_ALIVE,0,COORD_ALIVE.length) ) {
        //ignore message, its an alive message
        fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Alive Message"));

    } else if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_HEADER,0,COORD_HEADER.length) ) {
        try {
            CoordinationMessage cmsg = new CoordinationMessage(msg.getMessage());
            Member[] cmbr = cmsg.getMembers();
            fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Coord Msg Arrived("+Arrays.toNameString(cmbr)+")"));
            processCoordMessage(cmsg);
        }catch ( ChannelException x ) {
            log.error(sm.getString("nonBlockingCoordinator.processCoordinationMessage.failed"),x);
        }
    } else {
        super.messageReceived(msg);
    }
}
 
Example 4
Source File: NonBlockingCoordinator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_ALIVE,0,COORD_ALIVE.length) ) {
        //ignore message, its an alive message
        fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Alive Message"));

    } else if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_HEADER,0,COORD_HEADER.length) ) {
        try {
            CoordinationMessage cmsg = new CoordinationMessage(msg.getMessage());
            Member[] cmbr = cmsg.getMembers();
            fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Coord Msg Arrived("+Arrays.toNameString(cmbr)+")"));
            processCoordMessage(cmsg, msg.getAddress());
        }catch ( ChannelException x ) {
            log.error("Error processing coordination message. Could be fatal.",x);
        }
    } else {
        super.messageReceived(msg);
    }
}
 
Example 5
Source File: NonBlockingCoordinator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Override
public void messageReceived(ChannelMessage msg) {
    if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_ALIVE,0,COORD_ALIVE.length) ) {
        //ignore message, its an alive message
        fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Alive Message"));

    } else if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_HEADER,0,COORD_HEADER.length) ) {
        try {
            CoordinationMessage cmsg = new CoordinationMessage(msg.getMessage());
            Member[] cmbr = cmsg.getMembers();
            fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Coord Msg Arrived("+Arrays.toNameString(cmbr)+")"));
            processCoordMessage(cmsg, msg.getAddress());
        }catch ( ChannelException x ) {
            log.error("Error processing coordination message. Could be fatal.",x);
        }
    } else {
        super.messageReceived(msg);
    }
}
 
Example 6
Source File: FragmentationInterceptor.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();

}
 
Example 7
Source File: FragmentationInterceptor.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();
    
}
 
Example 8
Source File: FragmentationInterceptor.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
public void addMessage(ChannelMessage msg) {
    //remove the total messages
    msg.getMessage().trim(4);
    //get the msg nr
    int nr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    //remove the msg nr
    msg.getMessage().trim(4);
    frags[nr] = msg.getMessage();
    
}