Package de.fhkn.in.uce.stun.message

Examples of de.fhkn.in.uce.stun.message.MessageReader


        }

        @Override
        public Message call() throws Exception {
            Message result = null;
            final MessageReader messageReader = MessageReader
                    .createMessageReaderWithCustomAttributeTypeDecoder(new NATAttributeTypeDecoder());
            UnsecureTargetSideConnectionEstablishment.this.logger.debug(
                    "waiting for connection request message from {}", this.controlConnection.toString()); //$NON-NLS-1$
            while (this.controlConnection.isConnected()) {
                final Message inMessage = messageReader.readSTUNMessage(this.controlConnection.getInputStream());
                if (inMessage.isMethod(STUNMessageMethod.CONNECTION_REQUEST)) {
                    UnsecureTargetSideConnectionEstablishment.this.logger.debug("Got connection request message"); //$NON-NLS-1$
                    result = inMessage;
                    break;
                }
View Full Code Here


                STUNMessageMethod.BINDING);
        writer.writeMessage(request);
    }

    private Message receiveBindingResponseFromStunServer(final InputStream in) throws Exception {
        final MessageReader reader = MessageReader.createMessageReader();
        return reader.readSTUNMessage(in);
    }
View Full Code Here

    public boolean authenticate(final Socket toBeAuthenticated, final Set<CancelableTask> relatedHolePunchingTasks,
            final CancelableTask ownTask, final Object sharedLock) throws IOException {
        boolean result = false;
        logger.info("Trying to authenticate socket: {}", toBeAuthenticated); //$NON-NLS-1$
        final MessageWriter messageWriter = new MessageWriter(toBeAuthenticated.getOutputStream());
        final MessageReader messageReader = this.hpUtil.getCustomHolePunchingMessageReader();
        final Message receivedMessage = messageReader.readSTUNMessage(toBeAuthenticated.getInputStream());
        if ((receivedMessage.getMessageMethod() == STUNMessageMethod.AUTHENTICATE)
                && receivedMessage.hasAttribute(Token.class)) {
            final Token receivedToken = receivedMessage.getAttribute(Token.class);
            if (receivedToken.getToken().equals(this.authentikationToken)) {
                final Message tokenAckMessage = receivedMessage.buildSuccessResponse();
                synchronized (sharedLock) {
                    messageWriter.writeMessage(tokenAckMessage);
                    final Message receveidAckMessage = messageReader
                            .readSTUNMessage(toBeAuthenticated.getInputStream());
                    if (this.hpUtil.isAuthenticationAcknowledgmentMessage(receveidAckMessage)) {
                        logger.debug("Authentication successfull, stopping hole punching threads"); //$NON-NLS-1$
                        this.hpUtil.stopCancableTasksExceptOwnTask(relatedHolePunchingTasks, ownTask);
                        result = true;
View Full Code Here

        messageWriter.writeMessage(registerMessage);
    }

    @SuppressWarnings("unused")
    private Message receiveMessage() throws IOException {
        final MessageReader messageReader = MessageReader.createMessageReader();
        return messageReader.readSTUNMessage(this.socketToMediator.getInputStream());
    }
View Full Code Here

        connectionRequestMessage.addAttribute(authentificationToken);
        messageWriter.writeMessage(connectionRequestMessage);
    }

    private Message receiveMessage(final Socket controlConnection) throws IOException {
        final MessageReader messageReader = this.hpUtil.getCustomHolePunchingMessageReader();
        return messageReader.readSTUNMessage(controlConnection.getInputStream());
    }
View Full Code Here

    public boolean authenticate(final Socket toBeAuthenticated, final Set<CancelableTask> relatedHolePunchingTasks,
            final CancelableTask ownTask, final Object sharedLock) throws IOException {
        boolean result = false;
        logger.info("Trying to authenticate socket: {}", toBeAuthenticated); //$NON-NLS-1$
        final MessageWriter messageWriter = new MessageWriter(toBeAuthenticated.getOutputStream());
        final MessageReader messageReader = this.hpUtil.getCustomHolePunchingMessageReader();
        // sending authentication message
        final Message authenticationMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.AUTHENTICATE);
        authenticationMessage.addAttribute(new Token(this.authentikationToken));
        logger.info("Sending AuthenticationMessage: {}", authenticationMessage); //$NON-NLS-1$
        messageWriter.writeMessage(authenticationMessage);
        // receiving authentication acknowledgment message
        final Message reveivedAckMessage = messageReader.readSTUNMessage(toBeAuthenticated.getInputStream());
        if (this.hpUtil.isAuthenticationAcknowledgmentMessage(reveivedAckMessage)) {
            synchronized (sharedLock) {
                // sending second authentication acknowledgment message
                final Message secondAckMessage = reveivedAckMessage.buildSuccessResponse();
                messageWriter.writeMessage(secondAckMessage);
View Full Code Here

TOP

Related Classes of de.fhkn.in.uce.stun.message.MessageReader

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.