-
Notifications
You must be signed in to change notification settings - Fork 38
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
1 parent
07fc725
commit e2b316d
Showing
2 changed files
with
65 additions
and
0 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
59 changes: 59 additions & 0 deletions
59
...s/EducationOrganizationNetworkAssociationRelationshipsAuthorizationContextDataProvider.cs
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,59 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Licensed to the Ed-Fi Alliance under one or more agreements. | ||
// The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. | ||
// See the LICENSE and NOTICES files in the project root for more information. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using EdFi.Ods.Api.Security.AuthorizationStrategies.Relationships; | ||
using EdFi.Ods.Entities.Common.EdFi; | ||
using EdFi.Ods.Entities.NHibernate.EducationOrganizationNetworkAssociationAggregate.EdFi; | ||
|
||
namespace EdFi.Ods.Standard.Security.Authorization.Overrides | ||
{ | ||
/// <summary> | ||
/// Creates and returns an <see cref="RelationshipsAuthorizationContextData"/> instance for making authorization decisions for access to the edfi.EducationOrganizationNetworkAssociation table of the EducationOrganizationNetworkAssociation aggregate in the Ods Database. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
public class EducationOrganizationNetworkAssociationRelationshipsAuthorizationContextDataProvider<TContextData> : IRelationshipsAuthorizationContextDataProvider<IEducationOrganizationNetworkAssociation, TContextData> | ||
where TContextData : RelationshipsAuthorizationContextData, new() | ||
{ | ||
/// <summary> | ||
/// Creates and returns an <see cref="TContextData"/> instance based on the supplied resource. | ||
/// </summary> | ||
public TContextData GetContextData(IEducationOrganizationNetworkAssociation resource) | ||
{ | ||
if (resource == null) | ||
throw new ArgumentNullException("resource", "The 'educationOrganizationNetworkAssociation' resource for obtaining authorization context data cannot be null."); | ||
|
||
var entity = resource as EducationOrganizationNetworkAssociation; | ||
|
||
var contextData = new TContextData(); | ||
// contextData.EducationOrganizationNetworkId = entity.EducationOrganizationNetworkId == default(long) ? null as long? : entity.EducationOrganizationNetworkId; // Primary key property, Only Education Organization Id present | ||
contextData.EducationOrganizationId = entity.MemberEducationOrganizationId; // Primary key property, Role name applied | ||
return contextData; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and returns a signature key based on the resource, which can then be used to get and instance of IEdFiSignatureAuthorizationProvider | ||
/// </summary> | ||
public string[] GetAuthorizationContextPropertyNames() | ||
{ | ||
var properties = new string[] | ||
{ | ||
// "EducationOrganizationNetworkId", | ||
"MemberEducationOrganizationId", | ||
}; | ||
|
||
return properties; | ||
} | ||
|
||
/// <summary> | ||
/// Creates and returns an <see cref="RelationshipsAuthorizationContextData"/> instance based on the supplied resource. | ||
/// </summary> | ||
public TContextData GetContextData(object resource) | ||
{ | ||
return GetContextData((EducationOrganizationNetworkAssociation)resource); | ||
} | ||
} | ||
} |