Refactored password handling in Document. Now only the composite key is stored and not the plain password and key file URL. This for now breaks the change password dialog a bit. Needs to be addressed.

Started conceptualising for auto type functionality
This commit is contained in:
michael starke
2013-10-31 21:10:10 +01:00
parent 55b4ce648f
commit 8f6622102b
18 changed files with 399 additions and 106 deletions

View File

@@ -156,7 +156,7 @@
4C6D1D2B17858A250014C5A5 /* MacPass.icns in Resources */ = {isa = PBXBuildFile; fileRef = 4C6D1D2A17858A250014C5A5 /* MacPass.icns */; };
4C6FDD2117BC4F4C004AEEC8 /* KPKTestPlaceholder.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C6FDD2017BC4F4C004AEEC8 /* KPKTestPlaceholder.m */; };
4C701CBC178618A000581B88 /* 12_RemoteTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C701CBB178618A000581B88 /* 12_RemoteTemplate.pdf */; };
4C70D100179092F200652EE9 /* KPKPassword.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C70D0FF179092F200652EE9 /* KPKPassword.m */; };
4C70D100179092F200652EE9 /* KPKCompositeKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C70D0FF179092F200652EE9 /* KPKCompositeKey.m */; };
4C74DD07177BD1640034A9DB /* MPCustomFieldView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C74DD06177BD1640034A9DB /* MPCustomFieldView.m */; };
4C76155C1764C04C0015A1A6 /* GeneralSettings.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C76155E1764C04C0015A1A6 /* GeneralSettings.xib */; };
4C7615681764C0C40015A1A6 /* PasswordInputView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4C76156A1764C0C40015A1A6 /* PasswordInputView.xib */; };
@@ -250,6 +250,7 @@
4CEAF85717BA9B1D001307A6 /* Keepass2Key.xml in Resources */ = {isa = PBXBuildFile; fileRef = 4CEAF85617BA9B1D001307A6 /* Keepass2Key.xml */; };
4CEAF85B17BA9B44001307A6 /* KPKTestKeyfileParsing.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CEAF85A17BA9B44001307A6 /* KPKTestKeyfileParsing.m */; };
4CECB31717AC326D00EAFB0F /* KPKTestLegacyWriting.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CECB31617AC326D00EAFB0F /* KPKTestLegacyWriting.m */; };
4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */; };
4CEED1C617D7BD0E007180F1 /* NSError+Messages.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CEED1C517D7BD0E007180F1 /* NSError+Messages.m */; };
4CF29BF417879D0000851B60 /* 26_FileSaveTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */; };
4CF62B86179385D700B660B6 /* KPKAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CF62B85179385D700B660B6 /* KPKAttribute.m */; };
@@ -545,8 +546,8 @@
4C6FDD1F17BC4F4C004AEEC8 /* KPKTestPlaceholder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKTestPlaceholder.h; sourceTree = "<group>"; };
4C6FDD2017BC4F4C004AEEC8 /* KPKTestPlaceholder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestPlaceholder.m; sourceTree = "<group>"; };
4C701CBB178618A000581B88 /* 12_RemoteTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 12_RemoteTemplate.pdf; sourceTree = "<group>"; };
4C70D0FE179092F200652EE9 /* KPKPassword.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKPassword.h; sourceTree = "<group>"; };
4C70D0FF179092F200652EE9 /* KPKPassword.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = KPKPassword.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C70D0FE179092F200652EE9 /* KPKCompositeKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKCompositeKey.h; sourceTree = "<group>"; };
4C70D0FF179092F200652EE9 /* KPKCompositeKey.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = KPKCompositeKey.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
4C74DD05177BD1640034A9DB /* MPCustomFieldView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPCustomFieldView.h; sourceTree = "<group>"; };
4C74DD06177BD1640034A9DB /* MPCustomFieldView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPCustomFieldView.m; sourceTree = "<group>"; };
4C76155F1764C0590015A1A6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/GeneralSettings.xib; sourceTree = "<group>"; };
@@ -720,6 +721,8 @@
4CEAF85A17BA9B44001307A6 /* KPKTestKeyfileParsing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestKeyfileParsing.m; sourceTree = "<group>"; };
4CECB31517AC326D00EAFB0F /* KPKTestLegacyWriting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KPKTestLegacyWriting.h; sourceTree = "<group>"; };
4CECB31617AC326D00EAFB0F /* KPKTestLegacyWriting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KPKTestLegacyWriting.m; sourceTree = "<group>"; };
4CEE46DB181C301D006BF1E5 /* MPAutotypeDaemon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPAutotypeDaemon.h; sourceTree = "<group>"; };
4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPAutotypeDaemon.m; sourceTree = "<group>"; };
4CEED1C417D7BD0E007180F1 /* NSError+Messages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSError+Messages.h"; sourceTree = "<group>"; };
4CEED1C517D7BD0E007180F1 /* NSError+Messages.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+Messages.m"; sourceTree = "<group>"; };
4CF29BF317879D0000851B60 /* 26_FileSaveTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 26_FileSaveTemplate.pdf; sourceTree = "<group>"; };
@@ -1051,6 +1054,8 @@
4C4B7EF717A4B335000234C7 /* MPUniqueCharactersFormatter.m */,
4C224B4017DFCB2300FF6AEE /* MPNumericalInputFormatter.h */,
4C224B4117DFCB2400FF6AEE /* MPNumericalInputFormatter.m */,
4CEE46DB181C301D006BF1E5 /* MPAutotypeDaemon.h */,
4CEE46DC181C301D006BF1E5 /* MPAutotypeDaemon.m */,
);
name = Helper;
sourceTree = "<group>";
@@ -1466,8 +1471,8 @@
4CD3ABB1178F71B50073F5C5 /* Core */ = {
isa = PBXGroup;
children = (
4C70D0FE179092F200652EE9 /* KPKPassword.h */,
4C70D0FF179092F200652EE9 /* KPKPassword.m */,
4C70D0FE179092F200652EE9 /* KPKCompositeKey.h */,
4C70D0FF179092F200652EE9 /* KPKCompositeKey.m */,
4CD3ABB3178F71B50073F5C5 /* KPKTree.h */,
4CD3ABB4178F71B50073F5C5 /* KPKTree.m */,
4CD3ABBD178F72610073F5C5 /* KPKEntry.h */,
@@ -1940,8 +1945,9 @@
4CD3ABBF178F72610073F5C5 /* KPKEntry.m in Sources */,
4CD3ABC2178F72720073F5C5 /* KPKGroup.m in Sources */,
4C591B57178F897A0080B16B /* KPKBinary.m in Sources */,
4CEE46DD181C301D006BF1E5 /* MPAutotypeDaemon.m in Sources */,
4C39B3F5178FEFAE0027DC7C /* KPKNode.m in Sources */,
4C70D100179092F200652EE9 /* KPKPassword.m in Sources */,
4C70D100179092F200652EE9 /* KPKCompositeKey.m in Sources */,
4C8A173D1790AA41008B5C17 /* NSData+Keyfile.m in Sources */,
4C3F28541791EDFD00703281 /* KPKErrors.m in Sources */,
4C4436771792BE810099E220 /* KPKFormat.m in Sources */,
@@ -2171,7 +2177,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.8;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-lxml2";
SDKROOT = macosx;
SDKROOT = macosx10.8;
};
name = Debug;
};
@@ -2200,7 +2206,7 @@
HEADER_SEARCH_PATHS = "$(SDKROOT)/usr/include/libxml2/**";
MACOSX_DEPLOYMENT_TARGET = 10.8;
OTHER_LDFLAGS = "-lxml2";
SDKROOT = macosx;
SDKROOT = macosx10.8;
};
name = Release;
};

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4510" systemVersion="12F45" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="4514" systemVersion="13A603" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment version="1070" defaultVersion="1080" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4510"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="4514"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MPEntryInspectorViewController">
@@ -31,7 +31,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="82">
<rect key="frame" x="67" y="505" width="159" height="19"/>
<rect key="frame" x="68" y="505" width="158" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<segmentedCell key="cell" controlSize="small" alignment="left" style="texturedSquare" trackingMode="selectOne" id="238">
<font key="font" metaFont="smallSystem"/>
@@ -42,7 +42,7 @@
</segments>
</segmentedCell>
</segmentedControl>
<tabView autoresizesSubviews="NO" drawsBackground="NO" type="noTabsNoBorder" initialItem="110" translatesAutoresizingMaskIntoConstraints="NO" id="83">
<tabView drawsBackground="NO" type="noTabsNoBorder" initialItem="110" translatesAutoresizingMaskIntoConstraints="NO" id="83">
<rect key="frame" x="0.0" y="0.0" width="293" height="503"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<font key="font" metaFont="system"/>
@@ -50,13 +50,13 @@
<tabViewItem label="General" identifier="1" id="110">
<view key="view" id="111">
<rect key="frame" x="0.0" y="0.0" width="293" height="503"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Attachments" identifier="" id="109">
<view key="view" id="123">
<rect key="frame" x="0.0" y="0.0" width="293" height="503"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="124">
<rect key="frame" x="241" y="466" width="32" height="19"/>
@@ -73,7 +73,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="126">
<rect key="frame" x="17" y="469" width="79" height="14"/>
<rect key="frame" x="18" y="469" width="77" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="73" id="136"/>
@@ -84,14 +84,14 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="125" customClass="HNHScrollView">
<scrollView autohidesScrollers="YES" horizontalLineScroll="38" horizontalPageScroll="10" verticalLineScroll="38" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="125" customClass="HNHScrollView">
<rect key="frame" x="20" y="26" width="253" height="432"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="F3N-QI-Di5">
<rect key="frame" x="1" y="1" width="251" height="430"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="137">
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="36" rowSizeStyle="automatic" viewBased="YES" id="137">
<rect key="frame" x="0.0" y="0.0" width="251" height="430"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
@@ -125,7 +125,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSActionTemplate" id="152"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="145">
<rect key="frame" x="40" y="10" width="208" height="17"/>
<rect key="frame" x="41" y="10" width="206" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="151">
<font key="font" metaFont="system"/>
@@ -160,7 +160,7 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSActionTemplate" id="170"/>
</imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="166">
<rect key="frame" x="40" y="10" width="128" height="17"/>
<rect key="frame" x="41" y="10" width="126" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="171">
<font key="font" metaFont="system"/>
@@ -216,11 +216,11 @@
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" id="138">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="138">
<rect key="frame" x="1" y="147" width="52" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" id="139">
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="139">
<rect key="frame" x="37" y="1" width="16" height="2"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
@@ -237,11 +237,14 @@
<constraint firstAttribute="bottom" secondItem="125" secondAttribute="bottom" constant="26" id="281"/>
</constraints>
</view>
<connections>
<outlet property="initialFirstResponder" destination="124" id="HDR-d9-QyI"/>
</connections>
</tabViewItem>
<tabViewItem label="Fields" identifier="" id="108">
<view key="view" id="178">
<rect key="frame" x="0.0" y="0.0" width="293" height="503"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="179">
<rect key="frame" x="241" y="466" width="32" height="19"/>
@@ -258,7 +261,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="181">
<rect key="frame" x="17" y="469" width="80" height="14"/>
<rect key="frame" x="18" y="469" width="79" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Custom Fields" id="190">
<font key="font" metaFont="smallSystem"/>
@@ -266,14 +269,14 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<scrollView borderType="line" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="180" customClass="HNHScrollView">
<scrollView borderType="line" autohidesScrollers="YES" horizontalLineScroll="56" horizontalPageScroll="10" verticalLineScroll="56" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="180" customClass="HNHScrollView">
<rect key="frame" x="16" y="26" width="261" height="433"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" drawsBackground="NO" copiesOnScroll="NO" id="k8G-zp-BXZ">
<rect key="frame" x="1" y="1" width="259" height="431"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" viewBased="YES" id="193">
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" columnResizing="NO" multipleSelection="NO" autosaveColumns="NO" rowHeight="54" rowSizeStyle="automatic" viewBased="YES" id="193">
<rect key="frame" x="0.0" y="0.0" width="259" height="431"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
@@ -311,7 +314,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="200">
<rect key="frame" x="0.0" y="40" width="258" height="14"/>
<rect key="frame" x="1" y="40" width="256" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="210"/>
@@ -369,7 +372,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="223">
<rect key="frame" x="0.0" y="40" width="258" height="14"/>
<rect key="frame" x="1" y="40" width="256" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="229"/>
@@ -402,11 +405,11 @@
</subviews>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" id="192">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="192">
<rect key="frame" x="1" y="119" width="223" height="15"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" id="191">
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="191">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
@@ -423,6 +426,9 @@
<constraint firstAttribute="bottom" secondItem="180" secondAttribute="bottom" constant="26" id="280"/>
</constraints>
</view>
<connections>
<outlet property="initialFirstResponder" destination="179" id="wSu-XB-L1r"/>
</connections>
</tabViewItem>
</tabViewItems>
</tabView>
@@ -441,7 +447,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="52">
<rect key="frame" x="17" y="673" width="28" height="14"/>
<rect key="frame" x="18" y="673" width="28" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Title" id="71">
<font key="font" metaFont="smallSystem"/>
@@ -457,9 +463,12 @@
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="nextKeyView" destination="55" id="zdp-8L-2De"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="54">
<rect key="frame" x="17" y="617" width="58" height="14"/>
<rect key="frame" x="18" y="617" width="57" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Username" id="69">
<font key="font" metaFont="smallSystem"/>
@@ -484,9 +493,12 @@
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<connections>
<outlet property="nextKeyView" destination="60" id="1Df-fB-wSk"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="57">
<rect key="frame" x="17" y="561" width="25" height="14"/>
<rect key="frame" x="18" y="561" width="25" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="URL" id="66">
<font key="font" metaFont="smallSystem"/>
@@ -495,7 +507,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="58">
<rect key="frame" x="17" y="505" width="58" height="14"/>
<rect key="frame" x="18" y="505" width="57" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Password" id="65">
<font key="font" metaFont="smallSystem"/>
@@ -512,6 +524,7 @@
</buttonCell>
<connections>
<action selector="_popUpPasswordGenerator:" target="-2" id="272"/>
<outlet property="nextKeyView" destination="73" id="mM2-Gg-Hsi"/>
</connections>
</button>
<secureTextField verticalHuggingPriority="750" horizontalCompressionResistancePriority="249" translatesAutoresizingMaskIntoConstraints="NO" id="60" customClass="HNHRoundedSecureTextField">
@@ -525,6 +538,9 @@
<string>NSAllRomanInputSourcesLocaleIdentifier</string>
</allowedInputSourceLocales>
</secureTextFieldCell>
<connections>
<outlet property="nextKeyView" destination="61" id="5yc-GS-oVG"/>
</connections>
</secureTextField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="61">
<rect key="frame" x="201" y="473" width="31" height="25"/>
@@ -533,6 +549,9 @@
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<outlet property="nextKeyView" destination="59" id="ZRe-l9-kNq"/>
</connections>
</button>
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9">
<rect key="frame" x="20" y="155" width="212" height="260"/>
@@ -557,17 +576,20 @@
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="150" id="76"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" id="74">
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="74">
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" verticalHuggingPriority="750" id="75">
<scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="75">
<rect key="frame" x="195" y="1" width="16" height="258"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<connections>
<outlet property="nextKeyView" destination="7" id="1gD-Ub-O8g"/>
</connections>
</scrollView>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="10">
<rect key="frame" x="17" y="423" width="35" height="14"/>
<rect key="frame" x="18" y="423" width="35" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Notes" id="72">
<font key="font" metaFont="smallSystem"/>
@@ -576,12 +598,15 @@
</textFieldCell>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="7">
<rect key="frame" x="18" y="129" width="69" height="18"/>
<rect key="frame" x="18" y="129" width="67" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Expires" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="78">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<outlet property="nextKeyView" destination="8" id="SbJ-ZA-mXZ"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="8">
<rect key="frame" x="169" y="128" width="63" height="19"/>
@@ -590,6 +615,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="cellTitle"/>
</buttonCell>
<connections>
<outlet property="nextKeyView" destination="5" id="Yg4-Ua-HVe"/>
</connections>
</button>
<tokenField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="5">
<rect key="frame" x="20" y="20" width="212" height="77"/>
@@ -604,7 +632,7 @@
</tokenFieldCell>
</tokenField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6">
<rect key="frame" x="17" y="105" width="30" height="14"/>
<rect key="frame" x="18" y="105" width="29" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Tags" id="79">
<font key="font" metaFont="smallSystem"/>
@@ -660,7 +688,7 @@
</objects>
<resources>
<image name="26_FileSaveTemplate" width="16" height="16"/>
<image name="NSActionTemplate" width="15" height="15"/>
<image name="NSActionTemplate" width="14" height="14"/>
<image name="NSAddTemplate" width="8" height="8"/>
<image name="NSQuickLookTemplate" width="21" height="16"/>
<image name="NSRemoveTemplate" width="8" height="8"/>

View File

@@ -16,12 +16,14 @@
#import "MPStripLineBreaksTransformer.h"
#import "MPServerDaemon.h"
#import "MPLockDaemon.h"
#import "MPAutotypeDaemon.h"
#import "MPDocumentWindowController.h"
@interface MPAppDelegate () {
@private
MPServerDaemon *serverDaemon;
MPLockDaemon *lockDaemon;
MPAutotypeDaemon *autotypeDaemon;
BOOL _restoredWindows;
BOOL _shouldOpenFile;
}
@@ -82,6 +84,7 @@
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
serverDaemon = [[MPServerDaemon alloc] init];
lockDaemon = [[MPLockDaemon alloc] init];
autotypeDaemon = [[MPAutotypeDaemon alloc] init];
//autotypeDaemon = [[MPAutotypeDaemon alloc] init];
BOOL reopen = [[NSUserDefaults standardUserDefaults] boolForKey:kMPSettingsKeyReopenLastDatabaseOnLaunch];

View File

@@ -0,0 +1,16 @@
//
// MPAutotypeDaemon.h
// MacPass
//
// Created by Michael Starke on 26.10.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* The autotype daemon is repsonsible for registering the globa hotkey and to perform any autotype actions
*/
@interface MPAutotypeDaemon : NSObject
@end

261
MacPass/MPAutotypeDaemon.m Normal file
View File

@@ -0,0 +1,261 @@
//
// MPAutotypeDaemon.m
// MacPass
//
// Created by Michael Starke on 26.10.13.
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
//
#import "MPAutotypeDaemon.h"
#import "DDHotKeyCenter.h"
#import "MPPasteBoardController.h"
#import "MPDocument.h"
#import "KPKEntry.h"
#import <Carbon/Carbon.h>
/*
Autotype workflow:
run copy/paste with content
special keys:
Tab {TAB}
Enter {ENTER} or ~
Arrow Up {UP}
Arrow Down {DOWN}
Arrow Left {LEFT}
Arrow Right {RIGHT}
Insert {INSERT} or {INS}
Delete {DELETE} or {DEL}
Home {HOME}
End {END}
Page Up {PGUP}
Page Down {PGDN}
Backspace {BACKSPACE}, {BS} or {BKSP}
Break {BREAK}
Caps-Lock {CAPSLOCK}
Escape {ESC}
Windows Key {WIN} (equ. to {LWIN})
Windows Key: left, right {LWIN}, {RWIN}
Apps / Menu {APPS}
Help {HELP}
Numlock {NUMLOCK}
Print Screen {PRTSC}
Scroll Lock {SCROLLLOCK}
F1 - F16 {F1} - {F16}
Numeric Keypad + {ADD}
Numeric Keypad - {SUBTRACT}
Numeric Keypad * {MULTIPLY}
Numeric Keypad / {DIVIDE}
Numeric Keypad 0 to 9 {NUMPAD0} to {NUMPAD9}
Shift +
Ctrl ^
Alt %
+ {+}
^ {^}
% {%}
~ {~}
(, ) {(}, {)}
[, ] {[}, {]}
{, } {{}, {}}
special commands:
{DELAY X} Delays X milliseconds.
{CLEARFIELD} Clears the contents of the edit control that currently has the focus (only single-line edit controls).
{VKEY X}
*/
@implementation MPAutotypeDaemon
- (id)init {
self = [super init];
if (self) {
/*
Test the system for enabled access for assistive devices. Otherwise we cannot work properly
Use defaults to determine if global hotkey is enabled
[self _registerHotKey];
*/
}
return self;
}
- (void)didPressHotKey {
// copy items to pasteboard
NSArray *documents = [NSApp orderedDocuments];
MPDocument *currentDocument = nil;
for(MPDocument *openDocument in documents) {
if(NO == openDocument.encrypted) {
currentDocument = openDocument;
break;
}
}
/*
Determine the window title of the current front most application
Start searching the db for the best fit (based on title, then on window associations
*/
NSString *windowTitle = [self _frontMostWindowTitle];
NSLog(@"Looking for entries matching window title:%@", windowTitle);
return;
KPKEntry *selectedEntry = currentDocument.selectedEntry;
if(nil == currentDocument || nil == selectedEntry) {
return; // no open documents, no selected entry
}
/* Perform Autotype instead of dump pasting */
MPPasteBoardController *controller = [MPPasteBoardController defaultController];
if(selectedEntry.username) {
[controller copyObjects:@[selectedEntry.username]];
[self _pressKey:kVK_ANSI_V modifierFlags:kCGEventFlagMaskCommand];
}
if(selectedEntry.password) {
[self _pressKey:kVK_Tab modifierFlags:0];
[controller copyObjects:@[selectedEntry.password]];
[self _pressKey:kVK_ANSI_V modifierFlags:kCGEventFlagMaskCommand];
}
[self _pressKey:kVK_Return modifierFlags:0];
}
- (void)_registerHotKey {
[[DDHotKeyCenter sharedHotKeyCenter] registerHotKeyWithKeyCode:kVK_ANSI_M
modifierFlags:(NSCommandKeyMask | NSAlternateKeyMask )
target:self
action:@selector(didPressHotKey)
object:nil];
}
- (void)_pressKey:(CGKeyCode)keyCode modifierFlags:(CGEventFlags)flags {
CGEventRef pressKey = CGEventCreateKeyboardEvent (NULL, keyCode, YES);
CGEventRef releaseKey = CGEventCreateKeyboardEvent (NULL, keyCode, NO);
CGEventSetFlags(pressKey,0);
CGEventSetFlags(releaseKey, 0);
CGEventSetFlags(pressKey,flags);
CGEventSetFlags(releaseKey, flags);
CGEventPost(kCGSessionEventTap, pressKey);
CGEventPost(kCGSessionEventTap, releaseKey);
CFRelease(pressKey);
CFRelease(releaseKey);
}
- (NSString *)_frontMostWindowTitle {
NSRunningApplication *frontApplication = [[NSWorkspace sharedWorkspace] frontmostApplication];
NSArray *currentWindows = CFBridgingRelease(CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID));
for(NSDictionary *windowDict in currentWindows) {
NSNumber *processId = windowDict[(NSString *)kCGWindowOwnerPID];
if(processId && [processId isEqualToNumber:@(frontApplication.processIdentifier)]) {
return windowDict[(NSString *)kCGWindowName];
}
}
return nil;
}
/*
cody by Joe Turner http://www.cocoabuilder.com/archive/cocoa/242992-detect-keyboard-layout-for-cgkeycodes.html#243168
*/
- (CGKeyCode)keyCodeForKeyboard:(const UCKeyboardLayout *)uchrHeader character:(NSString *)character {
if ([character isEqualToString:@"RETURN"]) return kVK_Return;
if ([character isEqualToString:@"TAB"]) return kVK_Tab;
if ([character isEqualToString:@"SPACE"]) return kVK_Space;
if ([character isEqualToString:@"DELETE"]) return kVK_Delete;
if ([character isEqualToString:@"ESCAPE"]) return kVK_Escape;
if ([character isEqualToString:@"F5"]) return kVK_F5;
if ([character isEqualToString:@"F6"]) return kVK_F6;
if ([character isEqualToString:@"F7"]) return kVK_F7;
if ([character isEqualToString:@"F3"]) return kVK_F3;
if ([character isEqualToString:@"F8"]) return kVK_F8;
if ([character isEqualToString:@"F9"]) return kVK_F9;
if ([character isEqualToString:@"F11"]) return kVK_F11;
if ([character isEqualToString:@"F13"]) return kVK_F13;
if ([character isEqualToString:@"F16"]) return kVK_F16;
if ([character isEqualToString:@"F14"]) return kVK_F14;
if ([character isEqualToString:@"F10"]) return kVK_F10;
if ([character isEqualToString:@"F12"]) return kVK_F12;
if ([character isEqualToString:@"F15"]) return kVK_F15;
if ([character isEqualToString:@"HELP"]) return kVK_Help;
if ([character isEqualToString:@"HOME"]) return kVK_Home;
if ([character isEqualToString:@"PAGE UP"]) return kVK_PageUp;
if ([character isEqualToString:@"FORWARD DELETE"]) return kVK_ForwardDelete;
if ([character isEqualToString:@"F4"]) return kVK_F4;
if ([character isEqualToString:@"END"]) return kVK_End;
if ([character isEqualToString:@"F2"]) return kVK_F2;
if ([character isEqualToString:@"PAGE DOWN"]) return kVK_PageDown;
if ([character isEqualToString:@"F1"]) return kVK_F1;
if ([character isEqualToString:@"LEFT"]) return kVK_LeftArrow;
if ([character isEqualToString:@"RIGHT"]) return kVK_RightArrow;
if ([character isEqualToString:@"DOWN"]) return kVK_DownArrow;
if ([character isEqualToString:@"UP"]) return kVK_UpArrow;
UTF16Char theCharacter = [character characterAtIndex:0];
long i, j, k;
unsigned char *uchrData = (unsigned char *)uchrHeader;
UCKeyboardTypeHeader *uchrTable = uchrHeader->keyboardTypeList;
BOOL found = NO;
UInt16 virtualKeyCode;
for (i = 0; i < (uchrHeader->keyboardTypeCount) && !found; i++) {
UCKeyToCharTableIndex *uchrKeyIX;
UCKeyStateRecordsIndex *stateRecordsIndex;
if (uchrTable[i].keyStateRecordsIndexOffset != 0 ) {
stateRecordsIndex = (UCKeyStateRecordsIndex *) (((unsigned char*)uchrData) + (uchrTable[i].keyStateRecordsIndexOffset));
if ((stateRecordsIndex->keyStateRecordsIndexFormat) != kUCKeyStateRecordsIndexFormat) {
stateRecordsIndex = NULL;
}
}
else {
stateRecordsIndex = NULL;
}
uchrKeyIX = (UCKeyToCharTableIndex *)(((unsigned char *)uchrData) + (uchrTable[i].keyToCharTableIndexOffset));
if (kUCKeyToCharTableIndexFormat == (uchrKeyIX-> keyToCharTableIndexFormat)) {
for (j = 0; j < (uchrKeyIX->keyToCharTableCount) && !found; j++) {
UCKeyOutput *keyToCharData = (UCKeyOutput *) ( ((unsigned char*)uchrData) + (uchrKeyIX->keyToCharTableOffsets[j]) );
for (k = 0; k < (uchrKeyIX->keyToCharTableSize) && !found; k++) {
if (((keyToCharData[k]) & kUCKeyOutputTestForIndexMask) == kUCKeyOutputStateIndexMask) {
long theIndex = (kUCKeyOutputGetIndexMask & keyToCharData[k]);
if (stateRecordsIndex != NULL && theIndex <= stateRecordsIndex-> keyStateRecordCount) {
UCKeyStateRecord *theStateRecord = (UCKeyStateRecord *) (((unsigned char *) uchrData) + (stateRecordsIndex-> keyStateRecordOffsets[theIndex]));
if ((theStateRecord->stateZeroCharData) == theCharacter) {
virtualKeyCode = k;
found = YES;
}
} else {
if ((keyToCharData[k]) == theCharacter) {
virtualKeyCode = k;
found = YES;
}
}
} else if (((keyToCharData[k]) & kUCKeyOutputTestForIndexMask) == kUCKeyOutputSequenceIndexMask) {
} else if ( (keyToCharData[k]) == 0xFFFE || (keyToCharData[k]) == 0xFFFF ) {
} else {
if ((keyToCharData[k]) == theCharacter) {
virtualKeyCode = k;
found = YES;
}
}
}
}
}
}
return (CGKeyCode)virtualKeyCode;
}
@end

View File

@@ -19,7 +19,7 @@
#import "KPKTree.h"
#import "KPKMetaData.h"
#import "KPKNode+IconImage.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "HNHRoundedTextField.h"
#import "HNHRoundedSecureTextField.h"
@@ -121,7 +121,7 @@
- (IBAction)benchmarkRounds:(id)sender {
[self.benchmarkButton setEnabled:NO];
[KPKPassword benchmarkTransformationRounds:1 completionHandler:^(NSUInteger rounds) {
[KPKCompositeKey benchmarkTransformationRounds:1 completionHandler:^(NSUInteger rounds) {
[self.encryptionRoundsTextField setIntegerValue:rounds];
[self.benchmarkButton setEnabled:YES];
}];

View File

@@ -23,10 +23,10 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
@class KPKTree;
@class KPKBinary;
@class KPKAttribute;
@class KPKCompositeKey;
@interface MPDocument : NSDocument
@property (assign, readonly) BOOL hasPasswordOrKey;
@property (nonatomic, readonly, assign) BOOL encrypted;
@property (strong, readonly, nonatomic) KPKTree *tree;
@@ -34,8 +34,9 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
@property (weak, readonly) KPKGroup *trash;
@property (weak, readonly) KPKGroup *templates;
@property (nonatomic, copy) NSString *password;
@property (nonatomic, strong) NSURL *key;
@property (nonatomic, strong) KPKCompositeKey *compositeKey;
//@property (nonatomic, copy) NSString *password;
//@property (nonatomic, strong) NSURL *key;
@property (assign, readonly, getter = isReadOnly) BOOL readOnly;
@property (nonatomic, readonly, assign) KPKVersion versionForFileType;

View File

@@ -22,7 +22,7 @@
#import "KPKGroup.h"
#import "KPKTree.h"
#import "KPKTree+Serializing.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "KPKMetaData.h"
#import "KPKAttribute.h"
@@ -51,7 +51,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
@property (strong, nonatomic) KPKTree *tree;
@property (weak, nonatomic) KPKGroup *root;
@property (assign, nonatomic) BOOL hasPasswordOrKey;
@property (assign) BOOL readOnly;
@property (strong) NSURL *lockFileURL;
@@ -97,7 +96,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
if(self) {
_encryptedData = nil;
_didLockFile = NO;
_hasPasswordOrKey = NO;
_readOnly = NO;
self.tree = [KPKTree templateTree];
}
@@ -119,10 +117,9 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
}
- (BOOL)writeToURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError {
if(!self.hasPasswordOrKey) {
if(!self.compositeKey.hasPasswordOrKeyFile) {
return NO; // No password or key. No save possible
}
KPKPassword *password = [[KPKPassword alloc] initWithPassword:self.password key:self.key];
NSString *fileType = [self fileTypeFromLastRunSavePanel];
KPKVersion version = [[self class] versionForFileType:fileType];
if(version == KPKUnknownVersion) {
@@ -131,7 +128,7 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
}
return NO;
}
NSData *treeData = [self.tree encryptWithPassword:password forVersion:version error:outError];
NSData *treeData = [self.tree encryptWithPassword:self.compositeKey forVersion:version error:outError];
if(![treeData writeToURL:url options:0 error:outError]) {
NSLog(@"%@", [*outError localizedDescription]);
return NO;
@@ -216,25 +213,23 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
#pragma mark Lock/Unlock/Decrypt
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{
KPKPassword *passwordData = [[KPKPassword alloc] initWithPassword:password key:keyFileURL];
self.key = keyFileURL;
self.password = [password length] > 0 ? password : nil;
self.tree = [[KPKTree alloc] initWithData:_encryptedData password:passwordData error:error];
self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL];
self.tree = [[KPKTree alloc] initWithData:_encryptedData password:self.compositeKey error:error];
BOOL isUnlocked = (nil != self.tree);
if(isUnlocked) {
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentDidUnlockDatabaseNotification object:self];
}
else {
self.compositeKey = nil; // clear the key?
}
return isUnlocked;
}
- (void)lockDatabase:(id)sender {
KPKPassword *password = [[KPKPassword alloc] initWithPassword:self.password key:self.key];
NSError *error;
/* Locking needs to be lossless hence just use the XML format */
_encryptedData = [self.tree encryptWithPassword:password forVersion:KPKXmlVersion error:&error];
_encryptedData = [self.tree encryptWithPassword:self.compositeKey forVersion:KPKXmlVersion error:&error];
self.tree = nil;
}
@@ -251,20 +246,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
return self.tree.root;
}
- (void)setPassword:(NSString *)password {
if(![_password isEqualToString:password]) {
_password = [password copy];
[self _updateIsSecured];
}
}
- (void)setKey:(NSURL *)key {
if(![[_key absoluteString] isEqualToString:[key absoluteString]]) {
_key = key;
[self _updateIsSecured];
}
}
- (void)setSelectedGroup:(KPKGroup *)selectedGroup {
if(_selectedGroup != selectedGroup) {
_selectedGroup = selectedGroup;
@@ -485,13 +466,6 @@ typedef NS_ENUM(NSUInteger, MPAlertType) {
return [super validateUserInterfaceItem:anItem];
}
#pragma mark Private
- (void)_updateIsSecured {
BOOL securePassword = ([self.password length] > 0);
BOOL secureKey = (nil != self.key);
self.hasPasswordOrKey = (secureKey || securePassword);
}
- (void)_cleanupLock {
if(_didLockFile) {
[[NSFileManager defaultManager] removeItemAtURL:_lockFileURL error:nil];

View File

@@ -23,6 +23,7 @@
#import "MPContextToolbarButton.h"
#import "KPKTree.h"
#import "KPKCompositeKey.h"
typedef NS_ENUM(NSUInteger, MPAlertContext) {
MPAlertLossySaveWarning,
@@ -179,7 +180,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
return;
}
}
else if(!document.hasPasswordOrKey) {
else if(!document.compositeKey) {
_saveAfterPasswordChange = YES;
[self editPassword:sender];
return;
@@ -237,7 +238,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
return valid;
}
case MPActionLock:
return document.hasPasswordOrKey;
return document.compositeKey.hasPasswordOrKeyFile;
case MPActionToggleInspector:
return (nil != [_splitView superview]);
@@ -266,7 +267,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
return valid;
}
case MPActionLock:
return document.hasPasswordOrKey;
return document.compositeKey.hasPasswordOrKeyFile;
case MPActionToggleInspector:
return (nil != [_splitView superview]);
@@ -309,7 +310,7 @@ typedef NS_ENUM(NSUInteger, MPAlertContext) {
- (IBAction)lock:(id)sender {
MPDocument *document = [self document];
if(!document.hasPasswordOrKey) {
if(!document.compositeKey.hasPasswordOrKeyFile) {
return; // Document needs a password/keyfile to be lockable
}
if(document.encrypted) {

View File

@@ -79,13 +79,15 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
[scrollView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSView *clipView = [scrollView contentView];
NSView *tabView = [[self.tabView tabViewItemAtIndex:MPEntryTabGeneral] view];
NSTabViewItem *tabViewItem = [self.tabView tabViewItemAtIndex:MPEntryTabGeneral];
NSView *tabView = [tabViewItem view];
/*
DO NEVER SET setTranslatesAutoresizingMaskIntoConstraints on NSTabViewItem's view
[tabView setTranslatesAutoresizingMaskIntoConstraints:NO];
*/
[scrollView setDocumentView:self.generalView];
[tabView addSubview:scrollView];
[tabViewItem setInitialFirstResponder:scrollView];
NSDictionary *views = NSDictionaryOfVariableBindings(_generalView, scrollView);
[[scrollView superview] addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[scrollView]|"

View File

@@ -14,6 +14,7 @@
#import "NSData+Keyfile.h"
#import "KPKTree.h"
#import "KPKCompositeKey.h"
@interface MPPasswordEditWindowController ()
@@ -47,9 +48,10 @@
return;
}
self.showPassword = NO;
[self.passwordTextField setStringValue:_currentDocument.password ? _currentDocument.password : @""];
[self.passwordRepeatTextField setStringValue:[self.passwordTextField stringValue]];
self.keyURL = _currentDocument.key;
// TODO: fix initial view for password edit
//[self.passwordTextField setStringValue:_currentDocument.password ? _currentDocument.password : @""];
//[self.passwordRepeatTextField setStringValue:[self.passwordTextField stringValue]];
//self.keyURL = _currentDocument.key;
NSDictionary *negateOption = @{ NSValueTransformerNameBindingOption : NSNegateBooleanTransformerName };
[self.passwordTextField bind:@"showPassword" toObject:self withKeyPath:@"showPassword" options:nil];
@@ -82,8 +84,7 @@
#pragma mark Actions
- (IBAction)save:(id)sender {
_currentDocument.password = [self.passwordTextField stringValue];
_currentDocument.key = [self.keyfilePathControl URL];
_currentDocument.compositeKey = [[KPKCompositeKey alloc] initWithPassword:[self.passwordTextField stringValue] key:[self.keyfilePathControl URL]];
[self dismissSheet:NSRunStoppedResponse];
if(self.delegate && [self.delegate respondsToSelector:@selector(didFinishPasswordEditing:)]) {
[self.delegate didFinishPasswordEditing:YES];

View File

@@ -9,7 +9,7 @@
#import "KPKTestLegacyLoading.h"
#import "KPKTree+Serializing.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "KPKMetaData.h"
#import "KPKIcon.h"
@@ -18,14 +18,14 @@
@implementation KPKTestLegacyLoading
- (void)testValidFile {
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
NSData *data = [self _loadTestDataBase:@"Test_Password_1234" extension:@"kdb"];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
STAssertNotNil(tree, @"Loading should result in a tree object");
}
- (void)testWrongPassword {
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"wrongPassword" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"wrongPassword" key:nil];
NSData *data = [self _loadTestDataBase:@"KeePass1_native_test" extension:@"kdb"];
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:&error];
@@ -47,7 +47,7 @@
- (void)testMetaParsing {
NSData *data = [self _loadTestDataBase:@"KDB1_KeePassX_test" extension:@"kdb"];
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"test" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"test" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:NULL];
STAssertNotNil(tree, @"Tree shoudl be loaded" );

View File

@@ -7,7 +7,7 @@
//
#import <SenTestingKit/SenTestingKit.h>
@class KPKPassword;
@class KPKCompositeKey;
@interface KPKTestLegacyWriting : SenTestCase

View File

@@ -8,7 +8,7 @@
#import "KPKTestLegacyWriting.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "KPKTree+Serializing.h"
@implementation KPKTestLegacyWriting
@@ -16,7 +16,7 @@
- (void)testWriting {
NSError __autoreleasing *error = nil;
NSURL *dbUrl = [self _urlForFile:@"CustomIcon_Password_1234" extension:@"kdbx"];
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithContentsOfUrl:dbUrl password:password error:&error];
STAssertNotNil(tree, @"Tree should be created");
error = nil;

View File

@@ -7,12 +7,12 @@
//
#import <SenTestingKit/SenTestingKit.h>
@class KPKPassword;
@class KPKCompositeKey;
@interface KPKTestXmlLoading : SenTestCase {
@private
NSData *_data;
KPKPassword *_password;
KPKCompositeKey *_password;
}
@end

View File

@@ -7,7 +7,7 @@
//
#import "KPKTestXmlLoading.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "KPKTree+Serializing.h"
#import "KPKEntry.h"
@@ -19,7 +19,7 @@
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Test_Password_1234" withExtension:@"kdbx"];
_data = [NSData dataWithContentsOfURL:url];
_password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
_password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
}
- (void)tearDown {
@@ -39,7 +39,7 @@
- (void)testAutotypeLoading {
NSBundle *myBundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [myBundle URLForResource:@"Autotype_test" withExtension:@"kdbx"];
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"test" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"test" key:nil];
NSError *error;
KPKTree *tree = [[KPKTree alloc] initWithContentsOfUrl:url password:password error:&error];
STAssertNotNil(tree, @"Tree shoud be loaded");

View File

@@ -7,7 +7,7 @@
//
#import "KPKTestXmlWriting.h"
#import "KPKPassword.h"
#import "KPKCompositeKey.h"
#import "KPKTree+Serializing.h"
@implementation KPKTestXmlWriting
@@ -15,7 +15,7 @@
- (void)testXmlWriting {
NSData *data = [self _loadTestDataBase:@"CustomIcon_Password_1234" extension:@"kdbx"];
NSError *error;
KPKPassword *password = [[KPKPassword alloc] initWithPassword:@"1234" key:nil];
KPKCompositeKey *password = [[KPKCompositeKey alloc] initWithPassword:@"1234" key:nil];
KPKTree *tree = [[KPKTree alloc] initWithData:data password:password error:&error];
error = nil;
NSData *saveData = [tree encryptWithPassword:password forVersion:KPKXmlVersion error:&error];