Skip to content

Commit

Permalink
Modified iOS agent to support IoT server
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan Perera committed Jan 20, 2017
1 parent 2398c2c commit e949bad
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 25 deletions.
32 changes: 22 additions & 10 deletions iOSMDMAgent/Base.lproj/LaunchScreen.xib
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
<device id="ipad9_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="669" height="924"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 WSO2. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2016 WSO2. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="883.5" width="629" height="20.5"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WSO2 iOS MDM Agent" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="WSO2 iOS IoT Agent" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="288" width="629" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="version 3.0.0" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l0h-1b-fIN">
<rect key="frame" x="263" y="360" width="142" height="78"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstItem="l0h-1b-fIN" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="64J-hy-ngA"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="l0h-1b-fIN" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="d5K-av-xxq"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
<point key="canvasLocation" x="29.5" y="258"/>
</view>
</objects>
</document>
17 changes: 10 additions & 7 deletions iOSMDMAgent/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="qTg-lr-Zb6">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="qTg-lr-Zb6">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -20,7 +23,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EFj-yl-pwy">
<frame key="frameInset" minX="214" minY="161" width="172" height="56"/>
<rect key="frame" x="214" y="161" width="172" height="56"/>
<constraints>
<constraint firstAttribute="height" constant="56" id="KJM-QB-sjp"/>
<constraint firstAttribute="width" constant="172" id="akQ-xs-BjR"/>
Expand Down Expand Up @@ -58,21 +61,21 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Set your server address here to start registration (i.e. www.abc.com)" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u7v-4T-Vc8">
<frame key="frameInset" minX="20" minY="69" width="560" height="70"/>
<rect key="frame" x="20" y="69" width="560" height="70"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="http://mdm.wso2.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eBV-H8-qQF">
<frame key="frameInset" minX="25" minY="164" width="550" height="30"/>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="http://iot.wso2.com" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="eBV-H8-qQF">
<rect key="frame" x="25" y="164" width="550" height="30"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
<connections>
<outlet property="delegate" destination="qTg-lr-Zb6" id="kZ9-1h-CJc"/>
</connections>
</textField>
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Y2Z-zP-a5q">
<frame key="frameInset" minX="200" minY="224" width="200" height="56"/>
<rect key="frame" x="200" y="224" width="200" height="56"/>
<constraints>
<constraint firstAttribute="width" constant="200" id="61u-uq-3SE"/>
<constraint firstAttribute="height" constant="56" id="QHu-jM-Zk7"/>
Expand Down
8 changes: 6 additions & 2 deletions iOSMDMAgent/Endpoints.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<key>OPERATION_URI</key>
<string>/operation/%@</string>
<key>REFRESH_TOKEN_URI</key>
<string>/oauth2/token</string>
<string>/token</string>
<key>UNENROLLMENT_PATH</key>
<string>/admin/devices/enterprise-wipe</string>
<key>SERVER_CONTEXT</key>
Expand All @@ -15,6 +15,10 @@
<key>LOCATION_PUBLISH_URI</key>
<string>/devices/location/%@</string>
<key>ENROLLMENT_URI</key>
<string>/emm-web-agent/enrollments/ios/login-agent</string>
<string>/ios-web-agent/enrollments/ios/login-agent</string>
<key>API_PORT</key>
<string>8243</string>
<key>ENROLMENT_PORT</key>
<string>9443</string>
</dict>
</plist>
22 changes: 16 additions & 6 deletions iOSMDMAgent/URLUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ @implementation URLUtils
NSString *const LOCATION_PUBLISH_URI = @"LOCATION_PUBLISH_URI";
NSString *const SERVER_URL = @"SERVER_URL";
NSString *const CONTEXT_URI = @"SERVER_CONTEXT";
NSString *const API_PORT = @"API_PORT";
NSString *const ENROLMENT_PORT = @"ENROLMENT_PORT";
NSString *const TOKEN = @"token";
NSString *const GET = @"GET";
NSString *const POST = @"POST";
Expand Down Expand Up @@ -55,37 +57,45 @@ + (NSString *)getServerURL {
}

+ (NSString *)getEnrollmentURL {
return [NSString stringWithFormat:@"%@%@", [URLUtils getServerURL], [[URLUtils readEndpoints] objectForKey:ENROLLMENT_URI]];
return [NSString stringWithFormat:@"%@:%@%@", [URLUtils getServerURL], [URLUtils getEnrolmentPort], [[URLUtils readEndpoints] objectForKey:ENROLLMENT_URI]];
}

+ (NSString *)getContextURL {
return [[URLUtils readEndpoints] objectForKey:CONTEXT_URI];
}

+ (NSString *)getAPIPort {
return [[URLUtils readEndpoints] objectForKey:API_PORT];
}

+ (NSString *)getEnrolmentPort {
return [[URLUtils readEndpoints] objectForKey:ENROLMENT_PORT];
}

+ (void)saveServerURL:(NSString *)serverURL {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:serverURL forKey:SERVER_URL];
[userDefaults synchronize];
}

+ (NSString *)getTokenPublishURL {
return [NSString stringWithFormat:@"%@%@%@", [URLUtils getServerURL], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:TOKEN_PUBLISH_URI]];
return [NSString stringWithFormat:@"%@:%@%@%@", [URLUtils getServerURL], [URLUtils getAPIPort], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:TOKEN_PUBLISH_URI]];
}

+ (NSString *)getLocationPublishURL {
return [NSString stringWithFormat:@"%@%@%@", [URLUtils getServerURL], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:LOCATION_PUBLISH_URI]];
return [NSString stringWithFormat:@"%@:%@%@%@", [URLUtils getServerURL], [URLUtils getAPIPort], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:LOCATION_PUBLISH_URI]];
}

+ (NSString *)getOperationURL {
return [NSString stringWithFormat:@"%@%@%@", [URLUtils getServerURL], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:OPERATION_URI]];
return [NSString stringWithFormat:@"%@:%@%@%@", [URLUtils getServerURL], [URLUtils getAPIPort], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:OPERATION_URI]];
}

+ (NSString *)getUnenrollURL {
return [NSString stringWithFormat:@"%@%@%@", [URLUtils getServerURL], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:UNENROLLMENT_PATH]];
return [NSString stringWithFormat:@"%@:%@%@%@", [URLUtils getServerURL], [URLUtils getAPIPort], [URLUtils getContextURL], [[URLUtils readEndpoints] objectForKey:UNENROLLMENT_PATH]];
}

+ (NSString *)getRefreshTokenURL{
return [NSString stringWithFormat:@"%@%@", [URLUtils getServerURL], [[URLUtils readEndpoints] objectForKey:REFRESH_TOKEN_URI]];
return [NSString stringWithFormat:@"%@:%@%@", [URLUtils getServerURL], [URLUtils getAPIPort], [[URLUtils readEndpoints] objectForKey:REFRESH_TOKEN_URI]];
}

@end

0 comments on commit e949bad

Please sign in to comment.