AgentsState IAgent.IsAuthorized(ISheduler sheduler, ShedulerState state) { var error = Authorize(state.Reader, state.Content, AuthenticationKind.User); var response = sheduler.GetCommand(state, AuthSchemes.Digest, GetAuthorizationError(error)); if (response.Command == AuthorizationCommands.TryAgain) { response.Writer.WriteXErrorDetails(GetError(error)); var realm = GetRealm(state.Reader); if (realm.IsValid) { WriteUnauthenticate(false, response.Writer, IsNonceStale(error), realm); } else { response.Writer.WriteXErrorDetails(GetError(ErrorCodes.InvalidDomain)); } } else if (response.Command == AuthorizationCommands.Cancel) { response.Writer.WriteXErrorDetails(GetError(error)); } return(new AgentsState(response)); }
public EveningSession(DateTime startTime, int maxDurartion, ISheduler sheduler) { StartTime = startTime; MaxDuration = maxDurartion; _sheduler = sheduler; }
public ApprovalProcessSaga(IUserInRoleRepository userInRoleRepository, IApprovalRepository approvalRepository, IPromotionRepository promotionRepository, ISheduler sheduler) { _userInRoleRepository = userInRoleRepository; _approvalRepository = approvalRepository; _promotionRepository = promotionRepository; _sheduler = sheduler; }
public TaskManager(ISheduler sheduler, DateTime morningDateTime, DateTime eveningDateTime, int morningMaxDuration, int eveningMaxDuration) { _sheduler = sheduler; MorningStartTime = morningDateTime; EveningStartTime = eveningDateTime; MorningDuration = morningMaxDuration; EveningDuration = eveningMaxDuration; }
AgentsState IAgent.IsAuthorized(ISheduler sheduler, ShedulerState state) { int opaque; bool proxy; ArraySegment <byte> token; var error = Authorize(state.Reader, scheme, out token, out opaque, out proxy); AuthorizationError error1; switch (error) { case ErrorCodes.Ok: error1 = AuthorizationError.Success; break; case ErrorCodes.Continue: error1 = AuthorizationError.Continue; break; case ErrorCodes.NoResponse: error1 = AuthorizationError.None; break; default: error1 = AuthorizationError.Failed; break; } var response = sheduler.GetCommand(state, scheme, error1); var targetname = state.Reader.RequestUri.Hostport.Host; if (response.Command == AuthorizationCommands.TryAgain) { response.Writer.WriteAuthenticateMs(proxy, scheme, targetname, realm, opaque); response.Writer.WriteXErrorDetails(GetError(error)); response.Writer.WriteDate(DateTime.UtcNow); } else if (response.Command == AuthorizationCommands.Continue) { response.Writer.WriteAuthenticateMs(proxy, scheme, targetname, realm, opaque, token); response.Writer.WriteDate(DateTime.UtcNow); } else if (response.Command == AuthorizationCommands.Cancel) { response.Writer.WriteXErrorDetails(GetError(error)); } return(new AgentsState(response)); }
AgentsState IAgent.IsAuthorized(ISheduler sheduler, ShedulerState state) { var error = IsAuthorizedInternal(sheduler, state, AuthenticationKind.User); var response = sheduler.GetCommand(state, AuthSchemes.Digest, GetAuthorizationError(error)); if (response.Command == AuthorizationCommands.TryAgain) { response.Writer.WriteXErrorDetails(GetError(error)); WriteAuthenticateDigest(false, response.Writer, IsNonceStale(error), state.Realm); } else if (response.Command == AuthorizationCommands.Cancel) { response.Writer.WriteXErrorDetails(GetError(error)); } return(new AuthorizationAgentsState <HttpMessageWriter>(response)); }
public void SchedulePerson(ISheduler sheduler) { sheduler.SchedulePlan(); }
public ErrorCodes IsAuthorizedInternal(ISheduler sheduler, ShedulerState shedulerState, AuthenticationKind kind) { var reader = shedulerState.Reader; var content = shedulerState.Content; IAccount account; var credentials = FindCredentials(reader, out account); if (credentials.AuthScheme != AuthSchemes.Digest) { return(ErrorCodes.NoResponse); } if (credentials.AuthAlgorithm == AuthAlgorithms.Other) { return(ErrorCodes.NotSupportedAuthAlgorithm); } if (credentials.Realm.IsInvalid) { return(ErrorCodes.RealmNotFound); } if (credentials.Realm.Equals(shedulerState.Realm) == false) { return(ErrorCodes.InvalidRealm); } if (credentials.Nonce.IsInvalid) { return(ErrorCodes.NonceNotFound); } if (credentials.MessageQop.IsValid) { if (credentials.Cnonce.IsInvalid) { return(ErrorCodes.CnonceNotFound); } } if (credentials.DigestUri.IsInvalid) { return(ErrorCodes.DigestUriNotFound); } if (credentials.Response.IsInvalid) { return(ErrorCodes.ResponseNotFound); } if (credentials.Nonce.Length != 32) { return(ErrorCodes.NonceInvalid); } if (credentials.Username.IsInvalid) { return(ErrorCodes.UsernmaeNotFound); } if (sheduler.ValidateAuthorization(reader, credentials.Username, shedulerState.Param) == false) { return(ErrorCodes.NotAuthorized); } Nonce nonce; if (Nonce.TryParse(credentials.Nonce.Bytes, credentials.Nonce.Begin, out nonce) == false) { return(ErrorCodes.FailedToParseNonce); } int opaque = nonce.DecodeOpaque(); AuthState state; if (authStates.TryGetValue(opaque, out state) == false) { return(ErrorCodes.AuthStateNotFound); } if (state.Nonce.IsEqualValue(nonce) == false) { return(ErrorCodes.NonceStale); } if (state.NonceCount >= credentials.NonceCount && state.IsNonceCountExpected) { return(ErrorCodes.NonceCountExpected); } var password = GetPassword(account.Id, credentials.Username); if (password == null) { return(ErrorCodes.FailedToRetriveUserPassword); } if (responseCalculator == null) { responseCalculator = new ResponseCalculator(); } var response = responseCalculator.GetResponseHexChars( credentials.Username, credentials.Realm, credentials.AuthAlgorithm == AuthAlgorithms.Md5Sess, credentials.Nonce, credentials.Cnonce, credentials.MessageQop, credentials.DigestUri, credentials.NonceCountBytes, reader.MethodBytes, content, new ByteArrayPart(password)); if (credentials.Response.Equals(response) == false) { return(ErrorCodes.WrongResponse); } state.NonceCount = credentials.NonceCount; state.LastAccess = unchecked (Environment.TickCount - 10000); authStates.Replace(state.Opaque, state); return(ErrorCodes.Ok); }
public TaskManager(ISheduler sheduler, MorningSession MorningSession, EveningSession eveningSession) { _sheduler = sheduler; _morningSession = MorningSession; }