-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
161 changed files
with
7,784 additions
and
2,707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright © Microsoft Open Technologies, Inc. | ||
// | ||
// All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
#pragma once | ||
|
||
typedef void (^ADAutoParamBlock)(NSDictionary<NSString *, NSString *> * parameters); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright © Microsoft Open Technologies, Inc. | ||
// | ||
// All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ADAutoAppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright © Microsoft Open Technologies, Inc. | ||
// | ||
// All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
#import "ADAutoAppDelegate.h" | ||
|
||
@interface ADAutoAppDelegate () | ||
|
||
@end | ||
|
||
@implementation ADAutoAppDelegate | ||
|
||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
// Override point for customization after application launch. | ||
return YES; | ||
} | ||
|
||
|
||
- (void)applicationWillResignActive:(UIApplication *)application { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
} | ||
|
||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "ADALAutomation.h" | ||
|
||
@interface ADAutoInputViewController : UIViewController | ||
|
||
- (id)initWithCompletionBlock:(ADAutoParamBlock)completionBlock; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// All rights reserved. | ||
// | ||
// This code is licensed under the MIT License. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files(the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions : | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#import "ADAutoInputViewController.h" | ||
#import "ADAutoTextAndButtonView.h" | ||
|
||
@interface ADAutoInputViewController () | ||
|
||
@end | ||
|
||
@implementation ADAutoInputViewController | ||
{ | ||
ADAutoParamBlock _completionBlock; | ||
ADAutoTextAndButtonView* _textAndButtonView; | ||
} | ||
|
||
- (id)initWithCompletionBlock:(ADAutoParamBlock)completionBlock | ||
{ | ||
if (!(self = [super init])) | ||
{ | ||
return nil; | ||
} | ||
|
||
_completionBlock = completionBlock; | ||
|
||
return self; | ||
} | ||
|
||
- (void)loadView | ||
{ | ||
UIView* contentView = [[UIView alloc] initWithFrame:UIScreen.mainScreen.bounds]; | ||
contentView.backgroundColor = UIColor.whiteColor; | ||
self.view = contentView; | ||
_textAndButtonView = [[ADAutoTextAndButtonView alloc] initWithFrame:UIScreen.mainScreen.bounds]; | ||
[contentView addSubview:_textAndButtonView]; | ||
[_textAndButtonView.actionButton addTarget:self | ||
action:@selector(go:) | ||
forControlEvents:UIControlEventTouchUpInside]; | ||
|
||
NSDictionary* views = @{ @"textAndButtonView" : _textAndButtonView, | ||
@"topLayoutGuide" : self.topLayoutGuide, | ||
@"bottomLayoutGuide" : self.bottomLayoutGuide }; | ||
|
||
NSArray* verticalConstraints = | ||
[NSLayoutConstraint constraintsWithVisualFormat:@"V:[topLayoutGuide]-[textAndButtonView]-[bottomLayoutGuide]" | ||
options:0 | ||
metrics:nil | ||
views:views]; | ||
|
||
NSArray* horizontalConstraints = | ||
[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-[textAndButtonView]-|" | ||
options:0 | ||
metrics:nil | ||
views:views]; | ||
|
||
[self.view addConstraints:verticalConstraints]; | ||
[self.view addConstraints:horizontalConstraints]; | ||
} | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view. | ||
} | ||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
- (IBAction)go:(id)sender | ||
{ | ||
(void)sender; | ||
|
||
@synchronized (self) | ||
{ | ||
NSString* text = _textAndButtonView.textView.text; | ||
NSError* error = nil; | ||
NSDictionary* params = [NSJSONSerialization JSONObjectWithData:[text dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error]; | ||
if (!params) | ||
{ | ||
params = @{ @"error" : error }; | ||
} | ||
|
||
_completionBlock(params); | ||
} | ||
} | ||
|
||
/* | ||
#pragma mark - Navigation | ||
// In a storyboard-based application, you will often want to do a little preparation before navigation | ||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | ||
// Get the new view controller using [segue destinationViewController]. | ||
// Pass the selected object to the new view controller. | ||
} | ||
*/ | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright © Microsoft Open Technologies, Inc. | ||
// | ||
// All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface ADAutoMainViewController : UIViewController | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright © Microsoft Open Technologies, Inc. | ||
// | ||
// All Rights Reserved | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS | ||
// OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION | ||
// ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A | ||
// PARTICULAR PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. | ||
// | ||
// See the Apache License, Version 2.0 for the specific language | ||
// governing permissions and limitations under the License. | ||
|
||
#import "ADAutoMainViewController.h" | ||
#import "ADAutoParameterViewController.h" | ||
#import "ADAutoInputViewController.h" | ||
#import "ADAL_Internal.h" | ||
|
||
@interface ADAutoMainViewController () | ||
|
||
@end | ||
|
||
@implementation ADAutoMainViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
// Do any additional setup after loading the view, typically from a nib. | ||
} | ||
|
||
|
||
- (void)didReceiveMemoryWarning { | ||
[super didReceiveMemoryWarning]; | ||
// Dispose of any resources that can be recreated. | ||
} | ||
|
||
|
||
- (IBAction)acquireToken:(id)sender | ||
{ | ||
/* ADAutoParameterViewController* paramController = | ||
[[ADAutoParameterViewController alloc] initWithParameters:@[@"userId", @"authority", @"clientId", @"resource", @"redirectUri"] | ||
completionBlock:^(NSDictionary<NSString *,NSString *> *parameters)*/ | ||
ADAutoInputViewController* inputController = | ||
[[ADAutoInputViewController alloc] initWithCompletionBlock:^(NSDictionary<NSString *,NSString *> *parameters) | ||
{ | ||
ADAuthenticationContext* context = | ||
[[ADAuthenticationContext alloc] initWithAuthority:parameters[@"authority"] | ||
validateAuthority:YES | ||
error:nil]; | ||
|
||
[context acquireTokenWithResource:parameters[@"resource"] | ||
clientId:parameters[@"clientId"] | ||
redirectUri:[NSURL URLWithString:parameters[@"redirectUri"]] | ||
completionBlock:^(ADAuthenticationResult *result) | ||
{ | ||
NSLog(@"Yay! %@", result); | ||
}]; | ||
}]; | ||
|
||
[self presentViewController:inputController animated:NO completion:^{ | ||
NSLog(@"presented!"); | ||
}]; | ||
} | ||
|
||
@end |
Oops, something went wrong.