Package de.fhkn.in.uce.plugininterface

Examples of de.fhkn.in.uce.plugininterface.NATBehavior


        this.mediatorConnection = new MediatorConnection();
    }

    @Override
    public Socket establishConnection(final String targetId, final ConnectionConfiguration config) {
        final NATBehavior sourceNat = this.investigator.investigateOwnNat(this.mediatorConnection
                .getControlConnection().getLocalPort());
        NATBehavior targetNat;
        try {
            logger.debug("Requesting nat of {}", targetId); //$NON-NLS-1$
            targetNat = this.requestTargetNatBehavior(targetId);
        } catch (final Exception e) {
            logger.error(e.getMessage());
            targetNat = new NATBehavior();
        }
        final NATSituation natSituation = new NATSituation(sourceNat, targetNat);
        logger.debug("Current nat situation: {}", natSituation.toString()); //$NON-NLS-1$
        List<NATTraversalTechniqueAttribute> supportedTravTechsByTarget = new ArrayList<NATTraversalTechniqueAttribute>();
        try {
View Full Code Here


        this.mediatorConnection.close();
        return connectedSocket;
    }

    private NATBehavior requestTargetNatBehavior(final String targetId) throws Exception {
        NATBehavior result = new NATBehavior();
        final Message requestMessage = MessageStaticFactory.newSTUNMessageInstance(STUNMessageClass.REQUEST,
                STUNMessageMethod.NAT_REQUEST);
        requestMessage.addAttribute(new Username(targetId));
        requestMessage.writeTo(this.mediatorConnection.getControlConnection().getOutputStream());
        final MessageReader messageReader = MessageReader
                .createMessageReaderWithCustomAttributeTypeDecoder(new NATAttributeTypeDecoder());
        final Message response = messageReader.readSTUNMessage(this.mediatorConnection.getControlConnection()
                .getInputStream());
        if (response.hasAttribute(NATBehavior.class)) {
            result = response.getAttribute(NATBehavior.class);
        }
        this.logger.debug("target {} is behind nat {}", targetId, result.toString()); //$NON-NLS-1$
        return result;
    }
View Full Code Here

                .getAllSupportedNATTraversalTechniques();
        final List<NATTraversalTechniqueAttribute> travTechAttributes = new ArrayList<NATTraversalTechniqueAttribute>();
        for (final NATTraversalTechnique supportedTraversalTechnique : supportedTraversalTechniques) {
            travTechAttributes.add(supportedTraversalTechnique.getMetaData().getAttribute());
        }
        final NATBehavior ownNatBehavior = this.investigator.investigateOwnNat(this.mediatorConnection
                .getControlConnection().getLocalPort());
        this.mediatorConnection.registerTarget(targetId, ownNatBehavior, travTechAttributes);
    }
View Full Code Here

    }

    private UserData createNewUserWithRequiredAttributes(final Message registerMessage, final Socket socketToUser)
            throws Exception {
        final Username username = registerMessage.getAttribute(Username.class);
        final NATBehavior userNat = registerMessage.getAttribute(NATBehavior.class);
        final List<NATTraversalTechniqueAttribute> supportedTravTechs = this
                .createListOfTechniquesFromMessage(registerMessage);
        return new UserData(username.getUsernameAsString(), userNat, socketToUser, supportedTravTechs);
    }
View Full Code Here

    @Override
    public void handleMessage(final Message message, final Socket controlConnection) throws Exception {
        this.mediatorUtil.checkForAttribute(message, Username.class);
        final Username username = message.getAttribute(Username.class);
        final UserData user = this.userList.getUserDataByUserId(username.getUsernameAsString());
        final NATBehavior userNat = user.getUserNat();
        final Message response = message.buildSuccessResponse();
        response.addAttribute(userNat);
        response.writeTo(controlConnection.getOutputStream());
        logger.debug("response to {}:{} sent", message.getMessageClass().toString(), message.getMessageMethod()
                .toString());
View Full Code Here

    @Override
    public NATBehavior investigateOwnNat(final int sourcePort) {
        final NATFeatureRealization mapping = this.investigateMappingBehavior(sourcePort);
        final NATFeatureRealization filtering = this.invetigateFilteringBehavior(sourcePort);
        final NATBehavior result = new NATBehavior(mapping, filtering);
        logger.debug("Current nat behavior: {}", result.toString()); //$NON-NLS-1$
        return result;
    }
View Full Code Here

    public Set<NATSituation> resolveWildcards(final NATSituation withWildcard) {
        // TODO refactor: divide and conquer
        final Set<NATSituation> result = new HashSet<NATSituation>();
        // resolve client
        final NATBehavior clientNat = withWildcard.getClientNATBehavior();
        final Set<NATBehavior> clientBehaviors = new HashSet<NATBehavior>();
        if (this.hasWildcard(clientNat)) {
            clientBehaviors.addAll(this.resolveWildcardInNatBehavior(clientNat));
        } else {
            clientBehaviors.add(clientNat);
        }
        // resolve server
        final NATBehavior serverNat = withWildcard.getServiceNATBehavior();
        final Set<NATBehavior> serverBehaviors = new HashSet<NATBehavior>();
        if (this.hasWildcard(serverNat)) {
            serverBehaviors.addAll(this.resolveWildcardInNatBehavior(serverNat));
        } else {
            serverBehaviors.add(serverNat);
View Full Code Here

        // TODO refactor
        final Set<NATBehavior> firstResult = new HashSet<NATBehavior>();
        final Set<NATBehavior> result = new HashSet<NATBehavior>();
        if (nat.getFeatureRealization(NATFeature.MAPPING).equals(NATFeatureRealization.DONT_CARE)) {
            for (NATFeatureRealization nonWildcard : this.getNonWildcardFeatureRealizations()) {
                NATBehavior newNatBehavior = new NATBehavior(nonWildcard,
                        nat.getFeatureRealization(NATFeature.FILTERING));
                firstResult.add(newNatBehavior);
            }
        } else {
            firstResult.add(nat);
        }
        for (NATBehavior natBehavior : firstResult) {
            if (natBehavior.getFeatureRealization(NATFeature.FILTERING).equals(NATFeatureRealization.DONT_CARE)) {
                for (NATFeatureRealization nonWildcard : this.getNonWildcardFeatureRealizations()) {
                    NATBehavior newNatBehavior = new NATBehavior(natBehavior.getFeatureRealization(NATFeature.MAPPING),
                            nonWildcard);
                    result.add(newNatBehavior);
                }
            } else {
                result.add(natBehavior);
View Full Code Here

    private Set<NATBehavior> getAllPossibleNATBehaviors() {
        final Set<NATBehavior> result = new HashSet<NATBehavior>();
        final Set<NATFeatureRealization> nonWildcards = this.getNonWildcardFeatureRealizations();
        for (NATFeatureRealization a : nonWildcards) {
            for (NATFeatureRealization b : nonWildcards) {
                result.add(new NATBehavior(a, b));
            }
        }
        return Collections.unmodifiableSet(result);
    }
View Full Code Here

TOP

Related Classes of de.fhkn.in.uce.plugininterface.NATBehavior

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.