//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public static OauthAccess FromCreateFabOauthAccess(CreateFabOauthAccess pApi) { var dom = new OauthAccess(); FromCreateFabOauthAccess(dom, pApi); return(dom); }
/*--------------------------------------------------------------------------------------------*/ private static void FromCreateFabOauthAccess(OauthAccess pDomain, CreateFabOauthAccess pApi) { FromCreateFabVertex(pDomain, pApi); pDomain.Token = pApi.Token; pDomain.Refresh = pApi.Refresh; pDomain.Expires = pApi.Expires; }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public FabOauthAccess AddAccess(IOperationContext pOpCtx, CreateOauthAccessOperation pCreateOp, long pMemberId, bool pClientMode = false) { ClearOldTokens(pOpCtx, pMemberId); const int expireSec = 3600; bool needsActiveMem = (pOpCtx.Auth.ActiveMemberId == null); CreateFabOauthAccess coa = new CreateFabOauthAccess(); coa.Token = pOpCtx.Code32; coa.Refresh = (pClientMode ? null : pOpCtx.Code32); coa.Expires = pOpCtx.UtcNow.AddSeconds(expireSec).Ticks; coa.AuthenticatesMemberId = pMemberId; if (needsActiveMem) { pOpCtx.Auth.SetFabricActiveMember(); } OauthAccess result = pCreateOp.Execute(pOpCtx, new CreateOperationBuilder(), new CreateOperationTasks(), coa); if (needsActiveMem) { pOpCtx.Auth.RemoveFabricActiveMember(); } return(new FabOauthAccess { AccessToken = result.Token, RefreshToken = result.Refresh, ExpiresIn = expireSec, TokenType = "bearer" }); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ protected override void TestSetUp() { base.TestSetUp(); vCreateOauthAccess = new CreateFabOauthAccess(); vCreateOauthAccess.AuthenticatesMemberId = (long)SetupMemberId.FabZach; vCreateOauthAccess.Expires = 92387523598; vCreateOauthAccess.Refresh = "12345678901234567890123456789012"; vCreateOauthAccess.Token = "abcd5678901234567890123456789XYZ"; }
/*--------------------------------------------------------------------------------------------*/ public virtual void AddOauthAccessAuthenticatesMember(ICreateOperationBuilder pCreCtx, OauthAccess pNewDom, CreateFabOauthAccess pNewCre, IWeaverVarAlias <OauthAccess> pAlias) { var a = AddEdge <OauthAccess, OauthAccessAuthenticatesMember, Member>( pCreCtx, pAlias, pNewCre.AuthenticatesMemberId); var maboaEdge = new MemberAuthenticatedByOauthAccess(); maboaEdge.Timestamp = pNewDom.Timestamp; AddReverseEdge(pCreCtx, a, maboaEdge, pAlias); }
public void AddOauthAccessAuthenticatesMember() { var dom = new OauthAccess { Timestamp = 9439439349 }; var cre = new CreateFabOauthAccess { AuthenticatesMemberId = 7272727 }; TestAddEdge( x => vTasks.AddOauthAccessAuthenticatesMember( x, dom, cre, GetAddVertexAlias <OauthAccess>()), cre.AuthenticatesMemberId, DbName.Edge.OauthAccessAuthenticatesMemberName, DbName.Edge.MemberAuthenticatedByOauthAccessName, new[] { DbName.Edge.MemberAuthenticatedByOauthAccess.Timestamp }, new object[] { dom.Timestamp } ); }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public CreateFabOauthAccessValidator(CreateFabOauthAccess pCreateObj) : base(pCreateObj) { vCreateObj = pCreateObj; }