Skip to content

Commit 13879ed

Browse files
author
kai
committed
Add new error type MSIDErrorBrokerXpcUnexpectedError for Broker XPC service on Mac
1 parent 8d5171b commit 13879ed

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

IdentityCore/src/MSIDError.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,9 @@ typedef NS_ENUM(NSInteger, MSIDErrorCode)
364364
// App state while failed to open broker error
365365
MSIDErrorBrokerAppIsInactive = -51902,
366366
MSIDErrorBrokerAppIsInBackground = -51903,
367+
368+
// Broker Xpc internal error
369+
MSIDErrorBrokerXpcUnexpectedError = -52001,
367370

368371
};
369372

IdentityCore/src/MSIDError.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ void MSIDFillAndLogError(NSError **error, MSIDErrorCode errorCode, NSString *err
447447
return @"MSIDErrorBrokerAppIsInactive";
448448
case MSIDErrorBrokerAppIsInBackground:
449449
return @"MSIDErrorBrokerAppIsInBackground";
450+
// Broker Xpc internal error
451+
case MSIDErrorBrokerXpcUnexpectedError:
452+
return @"MSIDErrorBrokerXpcUnexpectedError";
450453
}
451454

452455
return [NSString stringWithFormat:@"Unknown: %@", @(errorCode)];

IdentityCore/src/controllers/MSIDSilentController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ - (void)acquireTokenWithRequest:(MSIDSilentTokenRequest *)request
143143
self.currentRequest = nil;
144144
MSIDRequestCompletionBlock completionBlockWrapper = ^(MSIDTokenResult *fallResult, NSError *fallError)
145145
{
146-
// We don't have any meaningful information from fallback controller (edge case of SSO error) so we use the local controller result earlier
147-
if (!fallResult && (fallError.code == MSIDErrorSSOExtensionUnexpectedError))
146+
// We don't have any meaningful information from fallback controller (edge case of SSO/Xpc error) so we use the local controller result earlier
147+
if (!fallResult && (fallError.code == MSIDErrorSSOExtensionUnexpectedError || fallError.code == MSIDErrorBrokerXpcUnexpectedError))
148148
{
149149
completionBlock(result, error);
150150
}

IdentityCore/src/controllers/broker/mac/MSIDXpcInteractiveTokenRequestController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ - (BOOL)shouldFallback:(NSError *)error
113113
case ASAuthorizationErrorNotHandled:
114114
case ASAuthorizationErrorUnknown:
115115
case ASAuthorizationErrorFailed:
116-
case MSIDErrorSSOExtensionUnexpectedError:
116+
case MSIDErrorBrokerXpcUnexpectedError:
117117
shouldFallback = YES;
118118
}
119119

IdentityCore/src/util/mac/MSIDXpcSingleSignOnProvider.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ - (void)getXpcService:(id<MSIDXpcProviderCaching>)xpcProviderCache withContinueB
372372
if (!xpcProviderCache.xpcConfiguration)
373373
{
374374
MSID_LOG_WITH_CTX(MSIDLogLevelWarning, nil, @"[Entra broker] CLIENT - Code should not be triggerred at here", nil, nil);
375-
continueBlock(nil, nil, MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, @"[Entra broker] CLIENT - Xpc configuration is not available", nil, nil, nil, nil, nil, YES));
375+
continueBlock(nil, nil, MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, @"[Entra broker] CLIENT - Xpc configuration is not available", nil, nil, nil, nil, nil, YES));
376376
return;
377377
}
378378

@@ -399,7 +399,7 @@ - (void)getXpcService:(id<MSIDXpcProviderCaching>)xpcProviderCache withContinueB
399399
__block BOOL isConnectionErroredOut = NO;
400400
[connection resume];
401401
[connection setInterruptionHandler:^{
402-
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, @"[Entra broker] CLIENT -- dispatcher connection is interrupted", nil, nil, nil, nil, nil, YES);
402+
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, @"[Entra broker] CLIENT -- dispatcher connection is interrupted", nil, nil, nil, nil, nil, YES);
403403
if (!isConnectionErroredOut && continueBlock)
404404
{
405405
isConnectionErroredOut = YES;
@@ -408,7 +408,7 @@ - (void)getXpcService:(id<MSIDXpcProviderCaching>)xpcProviderCache withContinueB
408408
}];
409409

410410
[connection setInvalidationHandler:^{
411-
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, @"[Entra broker] CLIENT -- dispatcher connection is invalidated", nil, nil, nil, nil, nil, YES);
411+
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, @"[Entra broker] CLIENT -- dispatcher connection is invalidated", nil, nil, nil, nil, nil, YES);
412412
if (!isConnectionErroredOut && continueBlock)
413413
{
414414
isConnectionErroredOut = YES;
@@ -428,7 +428,7 @@ - (void)getXpcService:(id<MSIDXpcProviderCaching>)xpcProviderCache withContinueB
428428
[connection invalidate];
429429
if (error)
430430
{
431-
NSError *xpcUnexpectedError = MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, [NSString stringWithFormat:@"[Entra broker] CLIENT - get broker instance endpoint failed: %@", error], nil, nil, nil, nil, nil, YES);
431+
NSError *xpcUnexpectedError = MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, [NSString stringWithFormat:@"[Entra broker] CLIENT - get broker instance endpoint failed: %@", error], nil, nil, nil, nil, nil, YES);
432432
if (continueBlock) continueBlock(nil, nil, xpcUnexpectedError);
433433
return;
434434
}
@@ -453,12 +453,12 @@ - (void)getXpcService:(id<MSIDXpcProviderCaching>)xpcProviderCache withContinueB
453453

454454
[directConnection resume];
455455
[directConnection setInterruptionHandler:^{
456-
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, @"[Entra broker] CLIENT -- instance connection is interrupted", nil, nil, nil, nil, nil, YES);
456+
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, @"[Entra broker] CLIENT -- instance connection is interrupted", nil, nil, nil, nil, nil, YES);
457457
if (continueBlock) continueBlock(nil, nil, xpcError);
458458
}];
459459

460460
[directConnection setInvalidationHandler:^{
461-
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorSSOExtensionUnexpectedError, @"[Entra broker] CLIENT -- instance connection is invalidated", nil, nil, nil, nil, nil, YES);
461+
NSError *xpcError = MSIDCreateError(MSIDErrorDomain, MSIDErrorBrokerXpcUnexpectedError, @"[Entra broker] CLIENT -- instance connection is invalidated", nil, nil, nil, nil, nil, YES);
462462
if (continueBlock) continueBlock(nil, nil, xpcError);
463463
}];
464464

0 commit comments

Comments
 (0)