Skip to content

Commit 18837ca

Browse files
committed
- OCCapabilities: allow MDM/branding control over default values for block_password_removal in case block_password_removal is not provided by the server
- OCConnection: add option connection.block-password-removal-default and associated metadata to the class
1 parent 2f1ca96 commit 18837ca

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

ownCloudSDK/Connection/Capabilities/OCCapabilities.m

+10-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#import "OCCapabilities.h"
2020
#import "OCMacros.h"
2121
#import "OCConnection.h"
22+
#import "NSObject+OCClassSettings.h"
2223

2324
#define WithDefault(val,def) (((val)==nil)?(def):(val))
2425

@@ -664,24 +665,29 @@ - (OCCapabilityBool)publicSharingPasswordEnforcedForUploadOnly
664665
return (OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"enforced_for"][@"upload_only"], NSNumber));
665666
}
666667

668+
- (OCCapabilityBool)_blockPasswordRemovalDefault
669+
{
670+
return ([OCConnection classSettingForOCClassSettingsKey:OCConnectionBlockPasswordRemovalDefault]);
671+
}
672+
667673
- (OCCapabilityBool)publicSharingPasswordBlockRemovalForReadOnly
668674
{
669-
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_only"], NSNumber), @NO));
675+
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_only"], NSNumber), self._blockPasswordRemovalDefault));
670676
}
671677

672678
- (OCCapabilityBool)publicSharingPasswordBlockRemovalForReadWrite
673679
{
674-
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_write"], NSNumber), @NO));
680+
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_write"], NSNumber), self._blockPasswordRemovalDefault));
675681
}
676682

677683
- (OCCapabilityBool)publicSharingPasswordBlockRemovalForReadWriteDelete
678684
{
679-
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_write_delete"], NSNumber), @NO));
685+
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"read_write_delete"], NSNumber), self._blockPasswordRemovalDefault));
680686
}
681687

682688
- (OCCapabilityBool)publicSharingPasswordBlockRemovalForUploadOnly
683689
{
684-
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"upload_only"], NSNumber), @NO));
690+
return (WithDefault(OCTypedCast(_capabilities[@"files_sharing"][@"public"][@"password"][@"block_password_removal"][@"upload_only"], NSNumber), self._blockPasswordRemovalDefault));
685691
}
686692

687693
- (OCCapabilityBool)publicSharingExpireDateAddDefaultDate

ownCloudSDK/Connection/OCConnection.h

+1
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ extern OCClassSettingsKey OCConnectionPlainHTTPPolicy; //!< Either "warn" (for O
474474
extern OCClassSettingsKey OCConnectionAlwaysRequestPrivateLink; //!< Controls whether private links are requested with regular PROPFINDs.
475475
extern OCClassSettingsKey OCConnectionTransparentTemporaryRedirect; //!< Allows (TRUE) transparent handling of 307 redirects at the HTTP pipeline level.
476476
extern OCClassSettingsKey OCConnectionValidatorFlags; //!< Allows fine-tuning the behavior of the connection validator.
477+
extern OCClassSettingsKey OCConnectionBlockPasswordRemovalDefault; //!< Controls the value of the `block_password_removal`-based capabilities if the server provides no value for it. This controls whether passwords can be removed from an existing link even though passwords need to be enforced on creation as per capabilities.
477478

478479
extern OCConnectionOptionKey OCConnectionOptionRequestObserverKey;
479480
extern OCConnectionOptionKey OCConnectionOptionLastModificationDateKey; //!< Last modification date for uploads

ownCloudSDK/Connection/OCConnection.m

+13-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ + (OCClassSettingsIdentifier)classSettingsIdentifier
111111
OCConnectionPlainHTTPPolicy,
112112
OCConnectionAlwaysRequestPrivateLink,
113113
OCConnectionTransparentTemporaryRedirect,
114-
OCConnectionValidatorFlags
114+
OCConnectionValidatorFlags,
115+
OCConnectionBlockPasswordRemovalDefault
115116
]);
116117
}
117118

@@ -154,7 +155,8 @@ + (OCClassSettingsIdentifier)classSettingsIdentifier
154155
OCConnectionAllowCellular : @(YES),
155156
OCConnectionPlainHTTPPolicy : @"warn",
156157
OCConnectionAlwaysRequestPrivateLink : @(NO),
157-
OCConnectionTransparentTemporaryRedirect : @(NO)
158+
OCConnectionTransparentTemporaryRedirect : @(NO),
159+
OCConnectionBlockPasswordRemovalDefault : @(YES)
158160
});
159161
}
160162

@@ -349,6 +351,14 @@ + (OCClassSettingsMetadataCollection)classSettingsMetadata
349351
OCClassSettingsMetadataKeyCategory : @"Security",
350352
OCClassSettingsMetadataKeyFlags : @(OCClassSettingsFlagDenyUserPreferences)
351353
},
354+
355+
OCConnectionBlockPasswordRemovalDefault : @{
356+
OCClassSettingsMetadataKeyType : OCClassSettingsMetadataTypeBoolean,
357+
OCClassSettingsMetadataKeyDescription : @"If a server does not provide `block_password_removal` information as part of its capabilities, this option provides the fallback value controlling whether passwords can (value: false) or can not (value: true) be removed from an existing link even if capabilities otherwise indicate passwords need to be enforced for links.",
358+
OCClassSettingsMetadataKeyStatus : OCClassSettingsKeyStatusAdvanced,
359+
OCClassSettingsMetadataKeyCategory : @"Security",
360+
OCClassSettingsMetadataKeyFlags : @(OCClassSettingsFlagDenyUserPreferences)
361+
}
352362
});
353363
}
354364

@@ -3400,6 +3410,7 @@ - (NSError *)sendSynchronousRequest:(OCHTTPRequest *)request
34003410
OCClassSettingsKey OCConnectionAlwaysRequestPrivateLink = @"always-request-private-link";
34013411
OCClassSettingsKey OCConnectionTransparentTemporaryRedirect = @"transparent-temporary-redirect";
34023412
OCClassSettingsKey OCConnectionValidatorFlags = @"validator-flags";
3413+
OCClassSettingsKey OCConnectionBlockPasswordRemovalDefault = @"block-password-removal-default";
34033414

34043415
OCConnectionOptionKey OCConnectionOptionRequestObserverKey = @"request-observer";
34053416
OCConnectionOptionKey OCConnectionOptionLastModificationDateKey = @"last-modification-date";

0 commit comments

Comments
 (0)