diff --git a/Owncloud iOs Client/Login/Login/LoginViewController.h b/Owncloud iOs Client/Login/Login/LoginViewController.h index c653eaf4d1..ae5fa9d7da 100644 --- a/Owncloud iOs Client/Login/Login/LoginViewController.h +++ b/Owncloud iOs Client/Login/Login/LoginViewController.h @@ -28,8 +28,7 @@ extern NSString *loginViewControllerRotate; CGRect refreshButtonFrame; CGRect showPasswordButtonFrame; CGRect lockImageFrame; - CGRect okNokImageFrameFooter1; - CGRect okNokImageFrameFooter2; + CGRect okNokImageFrameFooter; CGRect textFooterFrame1; CGRect textFooterFrame2; CGRect footerSection1Frame; @@ -49,6 +48,7 @@ extern NSString *loginViewControllerRotate; BOOL isConnectionToServer; BOOL isNeedToCheckAgain; BOOL isHttps; + BOOL isHttpsSecure; BOOL isCheckingTheServerRightNow; BOOL isSSLAccepted; BOOL isErrorOnCredentials; diff --git a/Owncloud iOs Client/Login/Login/LoginViewController.m b/Owncloud iOs Client/Login/Login/LoginViewController.m index dfab3e487a..acd5c7ab9d 100644 --- a/Owncloud iOs Client/Login/Login/LoginViewController.m +++ b/Owncloud iOs Client/Login/Login/LoginViewController.m @@ -30,6 +30,9 @@ #import "UtilsFramework.h" #import "UtilsCookies.h" +#define k_http_prefix @"http://" +#define k_https_prefix @"https://" + NSString *loginViewControllerRotate = @"loginViewControllerRotate"; @interface LoginViewController () @@ -56,9 +59,9 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil isConnectionToServer = NO; isNeedToCheckAgain = YES; hasInvalidAuth = NO; + isHttpsSecure = NO; showPasswordCharacterButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [showPasswordCharacterButton setHidden:YES]; } return self; @@ -254,9 +257,6 @@ -(void) potraitViewiPhone { //Frame used for Loading icon, secure or not secure connection lockImageFrame = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for credential error - okNokImageFrameFooter1 = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for information message under the url field textFooterFrame1 = CGRectMake((lockImageFrame.origin.x + lockImageFrame.size.width + 15), 7.0, (self.view.frame.size.width - ((lockImageFrame.origin.x + lockImageFrame.size.width) * 2)), 25.0); @@ -276,10 +276,10 @@ -(void) potraitViewiPhone { footerSection1Frame = CGRectMake(0, 0, 320, 40); //Error image for bad credentials - okNokImageFrameFooter2 = CGRectMake(20.0, 7.5, 25.0, 25.0); + okNokImageFrameFooter = CGRectMake(20.0, 7.5, 25.0, 25.0); //Test with information about the problem - textFooterFrame2 = CGRectMake((okNokImageFrameFooter2.origin.x + okNokImageFrameFooter2.size.width + 15), 0, (self.view.frame.size.width - ((okNokImageFrameFooter2.origin.x + okNokImageFrameFooter2.size.width) * 2)), 40.0); + textFooterFrame2 = CGRectMake((okNokImageFrameFooter.origin.x + okNokImageFrameFooter.size.width + 15), 0, (self.view.frame.size.width - ((okNokImageFrameFooter.origin.x + okNokImageFrameFooter.size.width) * 2)), 40.0); @@ -326,9 +326,6 @@ -(void)landscapeViewiPhone{ //Frame used for Loading icon, secure or not secure connection lockImageFrame = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for credential error - okNokImageFrameFooter1 = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for information message under the url field textFooterFrame1 = CGRectMake((lockImageFrame.origin.x + lockImageFrame.size.width + 15), 5.0, (self.view.frame.size.width - (lockImageFrame.origin.x + lockImageFrame.size.width + 10)), 25.0); @@ -348,10 +345,10 @@ -(void)landscapeViewiPhone{ footerSection1Frame = CGRectMake(0, 0, 480, 40); //Error image for bad credentials - okNokImageFrameFooter2 = CGRectMake(20.0, 7.5, 25.0, 25.0); + okNokImageFrameFooter = CGRectMake(20.0, 7.5, 25.0, 25.0); //Test with information about the problem - textFooterFrame2 = CGRectMake((okNokImageFrameFooter2.origin.x + okNokImageFrameFooter2.size.width + 15), 0.0, 280.0, 40.0); + textFooterFrame2 = CGRectMake((okNokImageFrameFooter.origin.x + okNokImageFrameFooter.size.width + 15), 0.0, 280.0, 40.0); //HEADER OF THE TABLE WHEN THE ARE NOT URL FRAME @@ -395,9 +392,6 @@ -(void)landscapeViewiPhone5{ //Frame used for Loading icon, secure or not secure connection lockImageFrame = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for credential error - okNokImageFrameFooter1 = CGRectMake(20.0, 5.0, 25.0, 25.0); - //Frame used for information message under the url field textFooterFrame1 = CGRectMake((lockImageFrame.origin.x + lockImageFrame.size.width + 15), 5.0, (self.view.frame.size.width - (lockImageFrame.origin.x + lockImageFrame.size.width + 10)), 25.0); @@ -418,10 +412,10 @@ -(void)landscapeViewiPhone5{ footerSection1Frame = CGRectMake(0, 0, 568, 40); //Error image for bad credentials - okNokImageFrameFooter2 = CGRectMake(20.0, 7.5, 25.0, 25.0); + okNokImageFrameFooter = CGRectMake(20.0, 7.5, 25.0, 25.0); //Test with information about the problem - textFooterFrame2 = CGRectMake((okNokImageFrameFooter2.origin.x + okNokImageFrameFooter2.size.width + 15), 0.0, 280.0, 40.0); + textFooterFrame2 = CGRectMake((okNokImageFrameFooter.origin.x + okNokImageFrameFooter.size.width + 15), 0.0, 280.0, 40.0); @@ -466,9 +460,6 @@ -(void)potraitViewiPad{ //Frame used for Loading icon, secure or not secure connection lockImageFrame = CGRectMake(235.0, 5.0, 25.0, 25.0); - //Frame used for credential error - okNokImageFrameFooter1 = CGRectMake(235.0, 5.0, 25.0, 25.0); - //Frame used for information message under the url field textFooterFrame1 = CGRectMake(280.0, 7.0, 300.0, 25.0); @@ -488,7 +479,7 @@ -(void)potraitViewiPad{ footerSection1Frame = CGRectMake(0, 0, 685, 40); //Error image for bad credentials - okNokImageFrameFooter2 = CGRectMake(235.0, 7.5, 25.0, 25.0); + okNokImageFrameFooter = CGRectMake(235.0, 7.5, 25.0, 25.0); //Test with information about the problem textFooterFrame2 = CGRectMake(280, 0.0, 300.0, 40.0); @@ -540,10 +531,6 @@ -(void)landscapeViewiPad{ //Frame used for Loading icon, secure or not secure connection lockImageFrame = CGRectMake(368.0, 5.0, 25.0, 25.0); - - //Frame used for credential error - okNokImageFrameFooter1 = CGRectMake(368.0, 5.0, 25.0, 25.0); - //Frame used for information message under the url field textFooterFrame1 = CGRectMake(408.0, 7.0, 300.0, 25.0); @@ -565,7 +552,7 @@ -(void)landscapeViewiPad{ footerSection1Frame = CGRectMake(0, 0, 785, 40); //Error image for bad credentials - okNokImageFrameFooter2 = CGRectMake(368.0, 7.5, 25.0, 25.0); + okNokImageFrameFooter = CGRectMake(368.0, 7.5, 25.0, 25.0); //Test with information about the problem @@ -1076,8 +1063,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } } -- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section -{ +- (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if (section == 0) { if(k_hide_url_server) { return [self generateFooterForUsernameAndPassword]; @@ -1087,183 +1073,124 @@ - (UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSIntege } else if (section == 1) { if(!k_hide_url_server) { return [self generateFooterForUsernameAndPassword]; - }else{ + } else { return nil; } - } else { return nil; } } -(UIView *) configureViewForFooterURLServer { - if([self.auxUrlForReloadTable isEqualToString:@""] || mCheckAccessToServer.delegate == nil) { + UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; + + if (!([self.auxUrlForReloadTable isEqualToString:@""] || mCheckAccessToServer.delegate == nil)) { - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - return view; + UILabel *label = [self setTheDefaultStyleOfTheServerFooterLabel]; + UIImageView *errorImage; - } else { - if(isCheckingTheServerRightNow){ - - UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - - [activity setFrame:lockImageFrame]; - [activity startAnimating]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; - label.text = NSLocalizedString(@"testing_connection",nil); - label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByWordWrapping; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - label.textColor = [UIColor colorOfLoginText]; - label.numberOfLines = 0; - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - + if (isCheckingTheServerRightNow) { + UIActivityIndicatorView *activity = [self setTheActivityIndicatorWhileTheConnectionIsBeenEstablished]; [view addSubview:activity]; - [view addSubview:label]; - - return view; - - } else if(isConnectionToServer) { - - if (hasInvalidAuth){ - - UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; - [errorImage setFrame:okNokImageFrameFooter1]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; - label.text = NSLocalizedString(@"authentification_not_valid",nil); - label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByTruncatingTail; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - - label.textColor = [UIColor colorOfLoginText]; - label.numberOfLines = 1; + label.text = NSLocalizedString(@"testing_connection",nil); + } else if (isConnectionToServer) { + if (hasInvalidAuth) { + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; + label.text = NSLocalizedString(@"authentification_not_valid",nil); + label.numberOfLines = 1; [label setAdjustsFontSizeToFitWidth:YES]; - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - - [view addSubview:errorImage]; - [view addSubview:label]; - - return view; - - } else if (isHttps) { - - UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SecureConnectionIcon.png"]]; - [errorImage setFrame:lockImageFrame]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; - label.text = NSLocalizedString(@"secure_connection_established",nil); - label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByWordWrapping; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - label.textColor = [UIColor colorOfLoginText]; - label.numberOfLines = 0; - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - - [view addSubview:errorImage]; - [view addSubview:label]; - - return view; - + if (isHttpsSecure) { + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SecureConnectionIcon.png"]]; + label.text = NSLocalizedString(@"secure_connection_established",nil); + } else { + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NonSecureConnectionIcon.png"]]; + label.text = NSLocalizedString(@"https_non_secure_connection_established",nil); + } } else { - - UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NonSecureConnectionIcon.png"]]; - [errorImage setFrame:lockImageFrame]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; - label.text = NSLocalizedString(@"connection_established",nil); - label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByWordWrapping; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - label.textColor = [UIColor colorOfLoginText]; - label.numberOfLines = 0; - - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - - [view addSubview:errorImage]; - [view addSubview:label]; - - return view; + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"NonSecureConnectionIcon.png"]]; + label.text = NSLocalizedString(@"connection_established",nil); } } else { if(isSSLAccepted) { - - UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; - [errorImage setFrame:okNokImageFrameFooter1]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; label.text = [NSLocalizedString(@"server_instance_not_found",nil) stringByReplacingOccurrencesOfString:@"$appname" withString:appName]; - label.baselineAdjustment= UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByWordWrapping; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - label.textColor = [UIColor colorOfServerErrorText]; - label.numberOfLines = 0; - - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - - [view addSubview:errorImage]; - [view addSubview:label]; - if(k_hide_url_server) { - UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - [button setFrame:syncImageFrameForNoURL]; - [button setBackgroundImage:[UIImage imageNamed:@"ReconnectIcon.png"] forState:UIControlStateNormal]; - [button addTarget:self action:@selector(checkUrlManually) forControlEvents:UIControlEventTouchDown]; - + UIButton *button = [self setTheButtonForReconnectWithTheCurrentServer]; [view addSubview:button]; } - - return view; } else { - - UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; - [errorImage setFrame:okNokImageFrameFooter1]; - - UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; - label.backgroundColor = [UIColor clearColor]; + errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; label.text = NSLocalizedString(@"connection_declined",nil); - label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - label.lineBreakMode = NSLineBreakByWordWrapping; - label.textAlignment = NSTextAlignmentLeft; - label.font = [UIFont fontWithName:@"Arial" size:13]; - label.textColor = [UIColor darkGrayColor]; - label.numberOfLines = 0; - - - UIView *view = [[UIView alloc] initWithFrame:textFooterFrame1]; - - [view addSubview:errorImage]; - [view addSubview:label]; - - return view; } } + [errorImage setFrame:lockImageFrame]; + [view addSubview:errorImage]; + [view addSubview:label]; } + return view; +} + + +///----------------------------------- +/// @name setTheDefaultStyleOfTheServerFooterLabel +///----------------------------------- + +/** + * This method set the default parameters of the label located on the server footer + */ +- (UILabel *) setTheDefaultStyleOfTheServerFooterLabel { + UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame1]; + label.backgroundColor = [UIColor clearColor]; + label.baselineAdjustment = UIBaselineAdjustmentAlignCenters; + label.lineBreakMode = NSLineBreakByWordWrapping; + label.textAlignment = NSTextAlignmentLeft; + label.textColor = [UIColor colorOfLoginText]; + label.numberOfLines = 0; + label.font = [UIFont fontWithName:@"Arial" size:12.5]; + + return label; +} + + +///----------------------------------- +/// @name setTheActivityIndicatorWhileTheConnectionIsBeenEstablished +///----------------------------------- + +/** + * This method set the activity indicator in the label located on the server footer + */ +- (UIActivityIndicatorView *) setTheActivityIndicatorWhileTheConnectionIsBeenEstablished { + UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + [activity setFrame:lockImageFrame]; + [activity startAnimating]; + + return activity; +} + + +///----------------------------------- +/// @name setTheButtonForReconnectWithTheCurrentServer +///----------------------------------- + +/** + * This method set the button located on the server field for reconnect the server + */ +- (UIButton *) setTheButtonForReconnectWithTheCurrentServer { + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; + [button setFrame:syncImageFrameForNoURL]; + [button setBackgroundImage:[UIImage imageNamed:@"ReconnectIcon.png"] forState:UIControlStateNormal]; + [button addTarget:self action:@selector(checkUrlManually) forControlEvents:UIControlEventTouchDown]; + + return button; } -(UIView *) generateFooterForUsernameAndPassword { if(isError500) { UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; - [errorImage setFrame:okNokImageFrameFooter2]; + [errorImage setFrame:okNokImageFrameFooter]; UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame2]; label.backgroundColor = [UIColor clearColor]; @@ -1287,7 +1214,7 @@ -(UIView *) generateFooterForUsernameAndPassword { if(isErrorOnCredentials) { UIImageView *errorImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"CredentialsError.png"]]; - [errorImage setFrame:okNokImageFrameFooter2]; + [errorImage setFrame:okNokImageFrameFooter]; UILabel* label = [[UILabel alloc] initWithFrame:textFooterFrame2]; label.backgroundColor = [UIColor clearColor]; @@ -1630,22 +1557,22 @@ -(NSString *)getUrlToCheck { NSString *url = [self getUrlChecked:self.urlTextField.text]; - if([url hasPrefix:@"https://"]) { + if ([url hasPrefix:k_https_prefix]) { isNeedToCheckAgain = NO; isHttps=YES; url = [NSString stringWithFormat:@"%@", [self getUrlChecked: self.urlTextField.text]]; - } else if([url hasPrefix:@"http://"]) { + } else if ([url hasPrefix:k_http_prefix]) { isNeedToCheckAgain = NO; isHttps = NO; url = [NSString stringWithFormat:@"%@", [self getUrlChecked: self.urlTextField.text]]; - } else if(isNeedToCheckAgain) { + } else if (isNeedToCheckAgain) { isNeedToCheckAgain = YES; isHttps = YES; - url = [NSString stringWithFormat:@"%@%@",@"https://",[self getUrlChecked: self.urlTextField.text]]; + url = [NSString stringWithFormat:@"%@%@",k_https_prefix,[self getUrlChecked: self.urlTextField.text]]; } else { isNeedToCheckAgain = NO; isHttps = NO; - url = [NSString stringWithFormat:@"%@%@",@"http://",[self getUrlChecked: self.urlTextField.text]]; + url = [NSString stringWithFormat:@"%@%@",k_http_prefix,[self getUrlChecked: self.urlTextField.text]]; } return url; } @@ -1715,7 +1642,7 @@ -(void)updateInterfaceWithConnectionToTheServer:(BOOL)isConnection{ //[loginButton setEnabled:NO]; isLoginButtonEnabled = NO; - if(isConnection) { + if (isConnection) { isConnectionToServer = YES; //[loginButton setEnabled:YES]; isLoginButtonEnabled = YES; @@ -1733,13 +1660,11 @@ -(void)updateInterfaceWithConnectionToTheServer:(BOOL)isConnection{ } if (isConnectionToServer) { - if(isHttps) { - //testServerLabel.text = NSLocalizedString(@"secure_connection_established", nil); + if (isHttps) { UIImage *currentImage = [UIImage imageNamed: @"SecureConnectionIcon.png"]; [checkConnectionToTheServerImage setImage:currentImage]; [checkConnectionToTheServerImage setHidden:NO]; } else { - //testServerLabel.text = NSLocalizedString(@"connection_established", nil); UIImage *currentImage = [UIImage imageNamed: @"NonSecureConnectionIcon.png"]; [checkConnectionToTheServerImage setImage:currentImage]; [checkConnectionToTheServerImage setHidden:NO]; @@ -1747,17 +1672,14 @@ -(void)updateInterfaceWithConnectionToTheServer:(BOOL)isConnection{ } else { - if(isHttps && ![self.urlTextField.text hasPrefix:@"https://"]) { + if (isHttps && ![self.urlTextField.text hasPrefix:k_https_prefix]) { DLog(@"es HTTPS no hay conexión"); - [mCheckAccessToServer isConnectionToTheServerByUrl:[self getUrlToCheck]]; } else { UIImage *currentImage = [UIImage imageNamed: @"CredentialsError.png"]; [checkConnectionToTheServerImage setImage:currentImage]; [checkConnectionToTheServerImage setHidden:NO]; - - //testServerLabel.text = [NSLocalizedString(@"server_instance_not_found", nil) stringByReplacingOccurrencesOfString:@"$appname" withString:k_appname]; } } @@ -1765,8 +1687,6 @@ -(void)updateInterfaceWithConnectionToTheServer:(BOOL)isConnection{ [self.tableView reloadData]; isNeedToCheckAgain = YES; - - } ///----------------------------------- @@ -1810,17 +1730,17 @@ - (void) updateConnectString{ NSString *httpOrHttps = @""; if(isHttps) { - if([_urlTextField.text hasPrefix:@"https://"]) { + if([_urlTextField.text hasPrefix:k_https_prefix]) { httpOrHttps = @""; } else { - httpOrHttps = @"https://"; + httpOrHttps = k_https_prefix; } } else { - if([_urlTextField.text hasPrefix:@"http://"]) { + if([_urlTextField.text hasPrefix:k_http_prefix]) { httpOrHttps = @""; } else { - httpOrHttps = @"http://"; + httpOrHttps = k_http_prefix; } } @@ -1869,10 +1789,10 @@ - (void) checkIfServerAutentificationIsNormalFromURL { BOOL isInvalid = NO; - if (k_is_sso_active==YES) { + if (k_is_sso_active == YES) { isInvalid = NO; isLoginButtonEnabled = YES; - } else{ + } else { //Unkown, must be invalid isInvalid = YES; } @@ -1881,77 +1801,86 @@ - (void) checkIfServerAutentificationIsNormalFromURL { if (isInvalid) { hasInvalidAuth = YES; isLoginButtonEnabled = NO; - }else{ + } else { hasInvalidAuth = NO; } + [self checkTheSecurityOfTheRedirectedURL:response]; + [_tableView reloadData]; [self updateInterfaceWithConnectionToTheServer:YES]; - } failureRequest:^(NSHTTPURLResponse *response, NSError *error) { BOOL isInvalid = NO; if (k_is_sso_active == NO) { - //Get header related with autentication type NSString *autenticationType = [[response allHeaderFields] valueForKey:@"Www-Authenticate"]; if (autenticationType) { //Autentication type basic if ([autenticationType hasPrefix:@"Basic"]) { - //Valid isInvalid = NO; - - } else if ([autenticationType hasPrefix:@"Bearer"]){ - + } else if ([autenticationType hasPrefix:@"Bearer"]) { //Autentication type oauth if (k_is_oauth_active == YES) { //Check if is activate oauth isInvalid = NO; - - }else{ - //Invalid + } else { isInvalid = YES; } - - } - else{ + } else { //Unknown autentication type - - //Invalid isInvalid = YES; } - - }else{ + } else { //The server not return a Www-Authenticate header - //Invalid isInvalid = YES; - } - - }else{ + } else { //If sso_active the check does not fail isInvalid = YES; } - //Update the interface depend of if isInvalid or not if (isInvalid) { hasInvalidAuth = YES; isLoginButtonEnabled = NO; - }else{ + } else { hasInvalidAuth = NO; } + [self checkTheSecurityOfTheRedirectedURL:response]; [_tableView reloadData]; [self updateInterfaceWithConnectionToTheServer:YES]; - - }]; - +} + + +///----------------------------------- +/// @name checkTheSecurityOfTheRedirectedURL +///----------------------------------- + +/** + * This method checks if the redirected URL has a downgrade of the security + So, if the first URL has https but the redirected one has http, we show a message to the user + * + * @param repsonse -> NSHTTPURLResponse, the response of the server + */ +- (void) checkTheSecurityOfTheRedirectedURL: (NSHTTPURLResponse *)response { + //Check the security of the redirection + NSURL *redirectionURL = response.URL; + NSString *redirectionURLString = [redirectionURL absoluteString]; + + if (isHttps) { + if ([redirectionURLString hasPrefix:k_https_prefix]) { + isHttpsSecure = YES; + } else { + isHttpsSecure = NO; + } + } } @@ -2068,14 +1997,14 @@ -(void)createUserAndDataInTheSystemWithRequest:(NSArray *)items andCode:(int) re UserDto *userDto = [[UserDto alloc] init]; //We check if start with http or https to concat it - if([self.urlTextField.text hasPrefix:@"http://"] || [self.urlTextField.text hasPrefix:@"https://"]) { + if([self.urlTextField.text hasPrefix:k_http_prefix] || [self.urlTextField.text hasPrefix:k_https_prefix]) { userDto.url = [self getUrlChecked: self.urlTextField.text]; } else { if(isHttps) { - userDto.url = [NSString stringWithFormat:@"%@%@",@"https://", [self getUrlChecked: self.urlTextField.text]]; + userDto.url = [NSString stringWithFormat:@"%@%@",k_https_prefix, [self getUrlChecked: self.urlTextField.text]]; } else { - userDto.url = [NSString stringWithFormat:@"%@%@",@"http://", [self getUrlChecked: self.urlTextField.text]]; + userDto.url = [NSString stringWithFormat:@"%@%@",k_http_prefix, [self getUrlChecked: self.urlTextField.text]]; } } diff --git a/Owncloud iOs Client/SupportingFiles/Languages/de.lproj/Localizable.strings b/Owncloud iOs Client/SupportingFiles/Languages/de.lproj/Localizable.strings index 88f27273d9..7a210a9922 100644 --- a/Owncloud iOs Client/SupportingFiles/Languages/de.lproj/Localizable.strings +++ b/Owncloud iOs Client/SupportingFiles/Languages/de.lproj/Localizable.strings @@ -14,6 +14,7 @@ "testing_connection" = "Verbindung testen"; "server_instance_not_found" = "Server nicht gefunden"; "secure_connection_established" = "Sichere Verbindung hergestellt"; +"https_non_secure_connection_established" = "Weiterleitung über unsichere Verbindung"; "connection_established" = "Verbindung hergestellt"; "login_details" = "Anmeldedetails"; "username" = "Benutzer"; @@ -22,9 +23,9 @@ "cancel" = "Abbrechen"; "error_login_message" = "Bitte Zugangsdaten überprüfen und erneut probieren"; "ok" = "OK"; -"url_sample" = "http://a.b.c.d/owncloud/"; +"url_sample" = "Server-Adresse https://..."; "forbidden_characters" = "Das Passwort enthält ungültige Zeichen!"; -"server" = "Server-Adresse https://..."; +"server" = "Server"; "url" = "URL"; "session_expired" = "Die Sitzung ist abgelaufen"; "credentials_different_user" = "Die eingegebenen Zugangsdaten sind nicht vom selben Benutzer"; diff --git a/Owncloud iOs Client/SupportingFiles/Languages/en.lproj/Localizable.strings b/Owncloud iOs Client/SupportingFiles/Languages/en.lproj/Localizable.strings index 12b1ffe25d..c8639f24a9 100644 --- a/Owncloud iOs Client/SupportingFiles/Languages/en.lproj/Localizable.strings +++ b/Owncloud iOs Client/SupportingFiles/Languages/en.lproj/Localizable.strings @@ -14,6 +14,7 @@ "testing_connection" = "Testing Connection"; "server_instance_not_found" = "Server not found"; "secure_connection_established" = "Secure Connection Established"; +"https_non_secure_connection_established" = "Redirected through an unsecured route"; "connection_established" = "Connection Established"; "login_details" = "Login Details"; "username" = "Username"; diff --git a/Owncloud iOs Client/SupportingFiles/Languages/es.lproj/Localizable.strings b/Owncloud iOs Client/SupportingFiles/Languages/es.lproj/Localizable.strings index 3048aa2143..4e127b081f 100644 --- a/Owncloud iOs Client/SupportingFiles/Languages/es.lproj/Localizable.strings +++ b/Owncloud iOs Client/SupportingFiles/Languages/es.lproj/Localizable.strings @@ -14,6 +14,7 @@ "testing_connection" = "Probando conexión"; "server_instance_not_found" = "Servidor no encontrado"; "secure_connection_established" = "Conexión segura establecida"; +"https_non_secure_connection_established" = "Redirigido por una ruta insegura"; "connection_established" = "Conexión establecida"; "login_details" = "Detalles de inicio de sesión"; "username" = "Usuario"; diff --git a/Owncloud iOs Client/SupportingFiles/Languages/fr.lproj/Localizable.strings b/Owncloud iOs Client/SupportingFiles/Languages/fr.lproj/Localizable.strings index c382bdf3fc..51d8db776a 100644 --- a/Owncloud iOs Client/SupportingFiles/Languages/fr.lproj/Localizable.strings +++ b/Owncloud iOs Client/SupportingFiles/Languages/fr.lproj/Localizable.strings @@ -14,6 +14,7 @@ "testing_connection" = "Test de connexion"; "server_instance_not_found" = "Serveur introuvable"; "secure_connection_established" = "Connexion sécurisée établie"; +"https_non_secure_connection_established" = "Redirigée par une voie peu sûre"; "connection_established" = "Connexion établie"; "login_details" = "Informations de connexion"; "username" = "Identifiant"; diff --git a/Owncloud iOs Client/SupportingFiles/Languages/it.lproj/Localizable.strings b/Owncloud iOs Client/SupportingFiles/Languages/it.lproj/Localizable.strings index 2056e9ad48..00a951a351 100644 --- a/Owncloud iOs Client/SupportingFiles/Languages/it.lproj/Localizable.strings +++ b/Owncloud iOs Client/SupportingFiles/Languages/it.lproj/Localizable.strings @@ -14,6 +14,7 @@ "testing_connection" = "Prova la connessione"; "server_instance_not_found" = "Server non trovato"; "secure_connection_established" = "Connessione sicura stabilita"; +"https_non_secure_connection_established" = "Redirect da un percorso pericoloso"; "connection_established" = "Connessione stabilita"; "login_details" = "Dettagli sessione"; "username" = "Utente";