Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.bolt.runtime.BoltStateMachineState processRunMessage(org.neo4j.bolt.v1.messaging.request.RunMessage message, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        private BoltStateMachineState ProcessRunMessage(RunMessage message, StateMachineContext context)
        {
            try
            {
                long start = context.Clock().millis();
                StatementMetadata statementMetadata = ProcessRunMessage(message, context.ConnectionState().StatementProcessor);
                long end = context.Clock().millis();

                context.ConnectionState().onMetadata("fields", stringArray(statementMetadata.FieldNames()));
                context.ConnectionState().onMetadata("result_available_after", Values.longValue(end - start));

                return(_streamingState);
            }
            catch (AuthorizationExpiredException e)
            {
                context.HandleFailure(e, true);
                return(_failedState);
            }
            catch (Exception t)
            {
                context.HandleFailure(t, false);
                return(_failedState);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static boolean processAuthentication(String userAgent, java.util.Map<String,Object> authToken, org.neo4j.bolt.runtime.StateMachineContext context) throws org.neo4j.bolt.runtime.BoltConnectionFatality
        public static bool ProcessAuthentication(string userAgent, IDictionary <string, object> authToken, StateMachineContext context)
        {
            try
            {
                BoltStateMachineSPI boltSpi = context.BoltSpi();

                AuthenticationResult authResult = boltSpi.Authenticate(authToken);
                string username = authResult.LoginContext.subject().username();
                context.AuthenticatedAsUser(username, userAgent);

                StatementProcessor statementProcessor        = new TransactionStateMachine(boltSpi.TransactionSpi(), authResult, context.Clock());
                context.ConnectionState().StatementProcessor = statementProcessor;

                if (authResult.CredentialsExpired())
                {
                    context.ConnectionState().onMetadata("credentials_expired", Values.TRUE);
                }
                context.ConnectionState().onMetadata("server", Values.stringValue(boltSpi.Version()));
                boltSpi.UdcRegisterClient(userAgent);

                return(true);
            }
            catch (Exception t)
            {
                context.HandleFailure(t, true);
                return(false);
            }
        }