Breaking the wall
Upcoming SlideShare
Loading in...5
×
 

Breaking the wall

on

  • 1,447 views

How we manage to overcome some iOS SDK limitations

How we manage to overcome some iOS SDK limitations

Statistics

Views

Total Views
1,447
Slideshare-icon Views on SlideShare
1,434
Embed Views
13

Actions

Likes
0
Downloads
7
Comments
0

2 Embeds 13

https://www.linkedin.com 7
http://www.linkedin.com 6

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Breaking the wall Breaking the wall Presentation Transcript

  • Breaking the wall Taras Kalapun
  • DON’T PANIC
  • Google it :)
  • iccoss
  • Certificates switching
  • Certificates switching H ello! evice cert d ed u sers allow
  • Certificates switching H ello! evice cert d ed u sers allow Login! pass for user cert Hello! user cert
  • we tried...• NSURLConnection• GTMHTTPFetcher - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge• ASIHTTPRequest // Will send the certificate attached to the identity (SecIdentityRef) [request setClientCertificateIdentity:identity];• Wireshark... we failed!
  • Hacks that worked
  • • Using IP for first certificate#include <netdb.h>#include <arpa/inet.h>+ (NSString *)hostIPFromHostName:(NSString *)hostName { struct hostent *host = gethostbyname([hostName UTF8String]); if (host == NULL) return nil; struct in_addr **list = (struct in_addr **)host->h_addr_list; NSString *addressString = [NSString stringWithUTF8String:inet_ntoa(*list[0])]; return addressString;}- (NSURL *)URLByUsingIP { NSString *oldHost = [NSString stringWithFormat:@"%@://%@", [self scheme], [self host]]; NSString *newHost = [NSString stringWithFormat:@"%@://%@", [self scheme], [NSURLhostIPFromHostName:[self host]]]; NSString *newUrl = [[self absoluteString] stringByReplacingOccurrencesOfString:oldHostwithString:newHost]; return [NSURL URLWithString:newUrl];}
  • • Adding “.” to the hostname ) http://developer.apple.com/library/ios/#qa/qa1727/NSString *oldHost = [NSString stringWithFormat:@"%@://%@", [self scheme], [self host]];NSString *newHost = [NSString stringWithFormat:@"%@://%@.", [self scheme], [self host]];NSString *newUrl = [[self absoluteString] stringByReplacingOccurrencesOfString:oldHost withString:newHost];return [NSURL URLWithString:newUrl];
  • )in Da dc r)0 ta * gne d cha Da nsi e :( NS , (u nsign c3 (u ata 0x ESD ar) xe2, ch )0 dD 5 An ned charMD sig d (un signe b, un 0x7 ( #include <Openssl/crypto.h> = ar) x22, h )0 #include <Openssl/evp.h> ] dc r gne d cha nsi e #include <Openssl/err.h> , (u nsign a8 (u #include <Openssl/x509.h> t; , Sal x53 *)g har dc si gne ( un t= );sal (gSalt f zeo ; 7 !");=1 e8 db PBEWithMD5AndDES sh oul { 8) ength= tl al@"s nil; tx; erC iph Xc ult s ER _CT f res g]; PH e o lts; trin s]; rag esu F8S yte sto R UT ta b C, ted ar *m 0; ord nDa ES _CB a loc d ch sw *)[i ndD n= pas ar e ign sults Le =[ ch D5 A Re o rd ned it hM sw sig tm Pas (un h]; beW *c = t D_p har ata leng (NI n); st c *m D ta set e con h ar [inDa ; be_ saltL p t, dc = s() S5_ al i gne taLen thm = PKC ns, s uns Da ori o t m alg ithm terati ll_ or in _a g i )); ), add R *al Ctx w ord ay_ O her ass S SLe _ALG ( cip (cP 9 eof len X50 siz , str )) 0, ord on C tx, s sw irecti her ); cPa ,d (& cip ) rC tx) m, rCtx) pt ULL th set phe ori ciphe cry me m =N (ci alg ( nd e m! n it(& -> er, & ro rith X_i thm et ina to lgo CT ori aram if ( a ER_ (alg p 1); x); ter m PH Init m-> tx, rCt null { _CI her th erC phe r EVP _Cip lgori ciph &ci s 1 fo ); e( lu PBE a g(& siz p en VP_ din ck_ ; // allocL if ( E pad lo 1 X_b ze + alloc( _s et_ CT Si TX ER_ lock SSL_m R_C PH { PH E _CI + b PEN _CI EVP taLen ar *)O Len )) E VP = Da ch n ize ; s, i
  • Testing compatibility Server/Client JSON iOSJAVA
  • Continuous Integration + Unit Testing• On commit, build Server• Server generates JSON to text files• Build Client, test with JSON files
  • #import <OCMock/OCMock.h>- (void)setUp { self.dataController = [DataController sharedDataController]; id mock = [OCMockObject partialMockForObject:self.dataController.dataAdapter]; [[[mock stub] andCall:@selector(fakeLoadUsersWithCompletionHandler:) onObject:self] loadUsersWithCompletionHandler:[OCMArg any]];}- (void)testLoadUsers { [self.dataController loadUsers];}#pragma mark - DataControllerDelegate- (void)dataController:(DataController *)adapter receivedUserList:(NSArray *)userList { STAssertTrue(([userList count] > 0), @"There should be some user logins"); NSLog(@"receivedUserList: %@", userList);}#pragma mark - Fakes- (void)fakeLoadUsersWithCompletionHandler:(void (^)(NSArray *items, NSError *error))handler { NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"getAllUsersOnDevice"ofType:@"txt"]; NSString *dataString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncodingerror:NULL]; STAssertNotNil(dataString, @"There should be some user list dump"); NSArray *users = [[dataString JSONValue] objectForKey:@"response"]; STAssertTrue(([users count] > 0), @"There should be some users in dump"); handler(users, NULL);}
  • iTunesmobileDeviceManager
  • iTunesmobileDeviceManager
  • • git://github.com/xslim/mobileDeviceManager.git• http://habrahabr.ru/blogs/macosxdev/113074/1. Поиск приложения по его идентификатору (необходимприложению для определения местоположения приложенияи его директорий).2. Отображение списка всех установленных приложений.3. Просмотр списка директорий.4. Просмотр содержания директорий.5. Копирование файлов с/на устройство.6. Определение подключено/отключено устройство.7. Просмотр папки Media и все вложенных в нее папок ифалов, и некоторые другие.
  • qCar
  • Gauges & Skins
  • - (void)layoutSubviews { ... CGSize bgSize = CGSizeFromString([self.skin objectForKey:@"bgSize"]); // Calculate aspect for other images CGFloat aspect = bgSize.width / self.bounds.size.width; // Background imSize = bgSize; imRect.origin = CGPointZero; imRect.size = CGSizeMake(imSize.width / aspect, imSize.height / aspect); self.bg.frame = imRect; // Arrow imSize = CGSizeFromString([self.skin objectForKey:@"arrowSize"]); // Calculate arrow position CGPoint bgAxis = CGPointFromString([self.skin objectForKey:@"bgAxis"]); CGPoint arrowAxis = CGPointFromString([self.skin objectForKey:@"arrowAxis"]); imRect.origin = CGPointMake((bgAxis.x - arrowAxis.x)/aspect, (bgAxis.y - arrowAxis.y)/aspect); imRect.size = CGSizeMake(imSize.width / aspect, imSize.height / aspect); self.arrow.layer.anchorPoint = CGPointMake(arrowAxis.x/imSize.width, arrowAxis.y/imSize.height); self.arrow.frame = imRect;
  • - (void)setValue:(float)aValue{ GaugeView *v = (id)self.view; float k = (arrowAngleMax - arrowAngleMin) / (scaleMax - scaleMin); float offset = (0 - scaleMin) / (scaleMax - scaleMin) * (arrowAngleMax - arrowAngleMin); float deg = k * aValue + offset; [UIView animateWithDuration:0.2f delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ v.arrow.transform = CGAffineTransformMakeRotation(DEGTORAD(deg)); } completion:nil];}
  • InfoSuit
  • Table realization
  • - (void)viewDidLoad{ CGRect tableRect = CGRectMake(0.0f, 0.0f, 800.0f, 320.0f); UITableView *table = [[UITableView alloc] initWithFrame:tableRectstyle:UITableViewStylePlain]; table.backgroundColor = [UIColor scrollViewTexturedBackgroundColor]; table.delegate = self; table.dataSource = self; self.tableView = table; [table release]; self.dataWidths = [self widthForData:self.data]; CGRect svRect = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f); UIScrollView *sv = [[UIScrollView alloc] initWithFrame:svRect]; sv.backgroundColor = self.tableView.backgroundColor; //sv.bounces = NO; sv.contentSize = self.tableView.frame.size; [sv addSubview:self.tableView]; [self.view addSubview:sv]; [sv release];}
  • - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{ static NSString *CellIdentifier = @"Cell"; ComplexTableViewCell *cell = (id)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[ComplexTableViewCell alloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:CellIdentifier] autorelease]; cell.dataWidth = self.dataWidths; } // Configure the cell... cell.data = [self.data objectAtIndex:indexPath.row]; return cell;}
  • - (void)drawRect:(CGRect)rect { if ([self.dataWidth count] < 1) return; CGContextRef ctx = UIGraphicsGetCurrentContext(); // Use the same color and width as the default cell separator for now CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0); CGContextSetLineWidth(ctx, 0.25); CGRect sRect = CGRectMake(2.0f, 1.0f, 10.0f, self.bounds.size.height - 2.0f); UIFont *font = [UIFont systemFontOfSize:14.0f]; int idx = 0; for (NSString *s in self.data) { CGFloat sWidth = [[self.dataWidth objectAtIndex:idx] floatValue]; //CGSize sSize = [s sizeWithFont:font]; sRect.size.width = sWidth; [s drawInRect:sRect withFont:font lineBreakMode:UILineBreakModeTailTruncation]; CGFloat linePoint = sRect.origin.x - 2.0f; CGContextMoveToPoint(ctx, linePoint, 0); CGContextAddLineToPoint(ctx, linePoint, self.bounds.size.height); sRect.origin.x += (sWidth + 4.0f); idx++; } CGContextStrokePath(ctx); [super drawRect:rect];}
  • Navigation bar coloring
  • swizzling
  • https://github.com/xslim/tools/tree/master/ UINavigationBar#include <objc/runtime.h>#include <objc/message.h>+ (void)load { Class class; Method method; Method drawRectCustomBackground = class_getInstanceMethod([UINavigationBar class],@selector(drawRectCustomBackground:)); Method drawRect = class_getInstanceMethod([UINavigationBar class], @selector(drawRect:)); method_exchangeImplementations(drawRect, drawRectCustomBackground);}
  • thx.Taras Kalapunt.kalapun@gmail.com@xslim
  • http://public.iwork.com/document/?d=Breaking_the_wall.key&a=p162685331