jens@0: // jens@0: // BLIPEndpoint.m jens@0: // MYNetwork jens@0: // jens@0: // Created by Jens Alfke on 5/14/08. jens@0: // Copyright 2008 Jens Alfke. All rights reserved. jens@0: // jens@0: jens@0: #import "TCPEndpoint.h" jens@26: #import "Test.h" jens@26: #import "CollectionUtils.h" jens@0: #import "ExceptionUtils.h" jens@26: #import jens@0: jens@0: jens@0: NSString* const kTCPPropertySSLClientSideAuthentication = @"kTCPPropertySSLClientSideAuthentication"; jens@0: jens@0: jens@0: @implementation TCPEndpoint jens@0: jens@0: jens@0: - (void) dealloc jens@0: { jens@0: [_sslProperties release]; jens@0: [super dealloc]; jens@0: } jens@0: jens@0: jens@0: - (NSMutableDictionary*) SSLProperties {return _sslProperties;} jens@0: jens@0: - (void) setSSLProperties: (NSMutableDictionary*)props jens@0: { jens@0: if( props != _sslProperties ) { jens@0: [_sslProperties release]; jens@0: _sslProperties = [props mutableCopy]; jens@0: } jens@0: } jens@0: jens@0: - (void) setSSLProperty: (id)value forKey: (NSString*)key jens@0: { jens@0: if( value ) { jens@0: if( ! _sslProperties ) jens@0: _sslProperties = [[NSMutableDictionary alloc] init]; jens@0: [_sslProperties setObject: value forKey: key]; jens@0: } else jens@0: [_sslProperties removeObjectForKey: key]; jens@0: } jens@0: jens@0: - (NSString*) securityLevel {return [_sslProperties objectForKey: (id)kCFStreamSSLLevel];} jens@0: - (void) setSecurityLevel: (NSString*)level {[self setSSLProperty: level forKey: (id)kCFStreamSSLLevel];} jens@0: jens@26: - (void) setPeerToPeerIdentity: (SecIdentityRef)identity { jens@26: Assert(identity); jens@26: self.SSLProperties = $mdict( jens@26: {(id)kCFStreamSSLLevel, NSStreamSocketSecurityLevelTLSv1}, jens@26: {kTCPPropertySSLCertificates, $array((id)identity)}, jens@26: {kTCPPropertySSLAllowsAnyRoot, $true}, jens@26: {kTCPPropertySSLPeerName, [NSNull null]}, jens@26: {kTCPPropertySSLClientSideAuthentication, $object(kTCPAlwaysAuthenticate)}); jens@26: } jens@0: jens@0: - (void) tellDelegate: (SEL)selector withObject: (id)param jens@0: { jens@0: if( [_delegate respondsToSelector: selector] ) { jens@0: @try{ jens@0: [_delegate performSelector: selector withObject: self withObject: param]; jens@0: }catchAndReport(@"%@ delegate",self.class); jens@0: } jens@0: } jens@0: jens@0: jens@0: @end jens@0: jens@0: jens@0: /* jens@0: Copyright (c) 2008, Jens Alfke . All rights reserved. jens@0: jens@0: Redistribution and use in source and binary forms, with or without modification, are permitted jens@0: provided that the following conditions are met: jens@0: jens@0: * Redistributions of source code must retain the above copyright notice, this list of conditions jens@0: and the following disclaimer. jens@0: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions jens@0: and the following disclaimer in the documentation and/or other materials provided with the jens@0: distribution. jens@0: jens@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR jens@0: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND jens@0: FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI- jens@0: BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES jens@0: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR jens@0: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN jens@0: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF jens@0: THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jens@0: */