src/net/java/sip/communicator/impl/protocol/sip/CallPeerMediaHandlerSipImpl.java
/**
     * Updates the supplied media description with SDES attributes if necessary.
     *
     * @param mediaType the media type.
     * @param localMd the description of the local peer.
     * @param remoteMd the description of the remote peer.
     * @return <tt>true</tt> if SDES has been added to the media description;
     * <tt>false</tt>, otherwise.
     */
Updates the supplied media description with SDES attributes if necessary.
@param mediaType the media type.
@param localMd the description of the local peer.
@param remoteMd the description of the remote peer.
@return true if SDES has been added to the media description;
false, otherwise.
Updates the supplied media description with SDES attributes if necessary . @param mediaType the media type . @param localMd the description of the local peer . @param remoteMd the description of the remote peer . @return true if SDES has been added to the media description ; false otherwise .
private boolean updateMediaDescriptionForSDes(
            MediaType mediaType,
            MediaDescription localMd,
            MediaDescription remoteMd)
    {
        AccountID accountID = getPeer().getProtocolProvider().getAccountID();
        if(!accountID.getAccountPropertyBoolean(
                    ProtocolProviderFactory.DEFAULT_ENCRYPTION,
                    true)
                || !accountID.isEncryptionProtocolEnabled(
                        SrtpControlType.SDES))
        {
            return false;
        }
        SrtpControls srtpControls = getSrtpControls();
        SDesControl sdesControl
            = (SDesControl)
                srtpControls.getOrCreate(mediaType, SrtpControlType.SDES);
        String ciphers
            = accountID.getAccountPropertyString(
                    ProtocolProviderFactory.SDES_CIPHER_SUITES);
        if (ciphers == null)
        {
            ciphers
                = SipActivator.getResources().getSettingsString(
                        SDesControl.SDES_CIPHER_SUITES);
        }
        sdesControl.setEnabledCiphers(Arrays.asList(ciphers.split(",")));
        if (remoteMd == null) 
        {
            @SuppressWarnings("unchecked")
            Vector<Attribute> atts = localMd.getAttributes(true);
            for (SrtpCryptoAttribute ca
                    : sdesControl.getInitiatorCryptoAttributes())
            {
                atts.add(SdpUtils.createAttribute("crypto", ca.encode()));
            }
            return true;
        }
        else 
        {
            SrtpCryptoAttribute localAttr
                = selectSdesCryptoSuite(false, sdesControl, remoteMd);
            if (localAttr != null)
            {
                try
                {
                    localMd.setAttribute("crypto", localAttr.encode());
                    return true;
                }
                catch (SdpException e)
                {
                    logger.error("unable to add crypto to answer", e);
                }
            }
            else
            {
                sdesControl.cleanup(null);
                srtpControls.remove(mediaType, SrtpControlType.SDES);
                logger.warn("Received unsupported sdes crypto attribute.");
            }
            return false;
        }
    }
private boolean updateMediaDescriptionForSDes ( MediaType mediaType , MediaDescription localMd , MediaDescription remoteMd ) { AccountID accountID = getPeer ( ) . getProtocolProvider ( ) . getAccountID ( ) ; if ( ! accountID . getAccountPropertyBoolean ( ProtocolProviderFactory . DEFAULT_ENCRYPTION , true ) || ! accountID . isEncryptionProtocolEnabled ( SrtpControlType . SDES ) ) { return false ; } SrtpControls srtpControls = getSrtpControls ( ) ; SDesControl sdesControl = ( SDesControl ) srtpControls . getOrCreate ( mediaType , SrtpControlType . SDES ) ; String ciphers = accountID . getAccountPropertyString ( ProtocolProviderFactory . SDES_CIPHER_SUITES ) ; if ( ciphers == null ) { ciphers = SipActivator . getResources ( ) . getSettingsString ( SDesControl . SDES_CIPHER_SUITES ) ; } sdesControl . setEnabledCiphers ( Arrays . asList ( ciphers . split ( "," ) ) ) ; if ( remoteMd == null ) { @ SuppressWarnings ( "unchecked" ) Vector < Attribute > atts = localMd . getAttributes ( true ) ; for ( SrtpCryptoAttribute ca : sdesControl . getInitiatorCryptoAttributes ( ) ) { atts . add ( SdpUtils . createAttribute ( "crypto" , ca . encode ( ) ) ) ; } return true ; } else { SrtpCryptoAttribute localAttr = selectSdesCryptoSuite ( false , sdesControl , remoteMd ) ; if ( localAttr != null ) { try { localMd . setAttribute ( "crypto" , localAttr . encode ( ) ) ; return true ; } catch ( SdpException e ) { logger . error ( "unable to add crypto to answer" , e ) ; } } else { sdesControl . cleanup ( null ) ; srtpControls . remove ( mediaType , SrtpControlType . SDES ) ; logger . warn ( "Received unsupported sdes crypto attribute." ) ; } return false ; } }
Updates the supplied media description with SDES attributes if necessary.
Updates the supplied media description with SDES attributes if necessary .
// Check if encryption and SDES are enabled at all. // get or create the control // set the enabled ciphers suites // act as initiator // act as responder // None of the offered suites match, destroy the SDES control.