/// <summary> /// Starts the configured connection listeners /// </summary> private void StartConnections() { IConnectionsConfiguration connectionConfig = (IConnectionsConfiguration)ConfigurationManager.GetSection("connections"); foreach (IListenerConfiguration listenerConfig in connectionConfig.Listeners) { _logger.DebugFormat("Listener configuration: {0}", listenerConfig.ListenerType); _logger.DebugFormat("\tWith parameters:"); foreach (KeyValuePair <string, string> parameter in listenerConfig.Parameters) { _logger.DebugFormat("\tname={0}; value={1}", parameter.Key, parameter.Value); } IFrontEndServerListener listener = GenericClassIdentifierFactory.CreateFromClassIdentifierOrType <IFrontEndServerListener>( listenerConfig.ListenerType, listenerConfig); if (listener == null) { _logger.FatalFormat("Cannot start listener '{0}', listener not found!", listenerConfig.ListenerType); throw new ArgumentException(string.Format("Cannot start listener '{0}', listener not found!", listenerConfig.ListenerType)); } _logger.InfoFormat("Listener '{0}' started succesfull (type={1})", listenerConfig.ListenerType, listener.GetType()); _listeners.Add(listener); listener.ClientConnected += HandleListenerClientConnected; listener.Listen(); } }
/// <summary> /// Reads the configured tpm devices from the configuration and /// sets up the corresponding tpm contexts /// </summary> private void SetupTPMContexts() { IConnectionsConfiguration connectionConfig = (IConnectionsConfiguration)ConfigurationManager.GetSection("connections"); foreach (Iaik.Tc.TPM.Configuration.DotNetConfiguration.TPMDevice device in connectionConfig.TpmDevices) { try { _logger.InfoFormat("Setting up tpm context '{0}'", device.TPMName); TPMWrapper tpmDevice = new TPMWrapper(); tpmDevice.Init(device.TPMType, device.Parameters); TPMContext tpmContext = new TPMContext(device.TPMName, tpmDevice); _tpmContexts.Add(device.TPMName, tpmContext); _logger.InfoFormat("Flushing device '{0}'", device.TPMName); foreach (TPMResourceType resourceType in new TPMResourceType[] { TPMResourceType.TPM_RT_AUTH, TPMResourceType.TPM_RT_KEY }) { Parameters listLoadedHandlesParameters = new Parameters(); listLoadedHandlesParameters.AddPrimitiveType("capArea", CapabilityData.TPMCapabilityArea.TPM_CAP_HANDLE); listLoadedHandlesParameters.AddPrimitiveType("handle_type", resourceType); TPMCommandRequest listLoadedHandlesRequest = new TPMCommandRequest(TPMCommandNames.TPM_CMD_GetCapability, listLoadedHandlesParameters); TPMCommandResponse response = tpmDevice.Process(listLoadedHandlesRequest); if (response.Status == false) { throw new Exception("An unknown tpm exception while flushing occured"); } foreach (uint handle in response.Parameters.GetValueOf <HandleList> ("handles")) { Parameters flushParameters = new Parameters(); flushParameters.AddValue("handle", HandleFactory.Create(resourceType, handle)); TPMCommandRequest flushRequest = new TPMCommandRequest(TPMCommandNames.TPM_CMD_FlushSpecific, flushParameters); TPMCommandResponse flushResponse = tpmDevice.Process(flushRequest); if (flushResponse.Status == false) { throw new Exception("Something went wrong while flushing"); } } } _logger.InfoFormat("Successfully setup tpm context '{0}' with type '{1}'", device.TPMName, device.TPMType); } catch (Exception ex) { _logger.FatalFormat("Error setting up tpm device '{0}', the device will not be available ({1})", device.TPMName, ex); } ///Set the Assembly search order for incoming Parameters so that core classes are always at first Parameters.AssemblySearchOrder = new Assembly[] { typeof(TPMWrapper).Assembly, //lib core typeof(ITypedParameter).Assembly }; //lib common } }
public DebugSubsystem(EndpointContext context, IConnectionsConfiguration config) : base(context, config) { _requestExecutionInfos.Add(DebugRequestsEnum.PrintOnServerConsole, BuildRequestExecutionInfo <DebugSubsystem, RequestPrintOnServerConsole, NoResponse>(HandlePrintOnServerConsoleRequest)); _requestExecutionInfos.Add(DebugRequestsEnum.PrintOnServerConsoleWithResponse, BuildRequestExecutionInfo <DebugSubsystem, RequestPrintOnServerConsoleWithResponse, ResponsePrintOnServerConsole>(HandlePrintOnServerConsoleWithResponseRequest)); }
public AuthenticationSubsystem(ServerContext ctx, IConnectionsConfiguration config) : base(ctx, config) { _requestExecutionInfos.Add(AuthenticationRequests.ListAuthenticationMechanisms, BuildRequestExecutionInfo <AuthenticationSubsystem, ListAuthenticationMechanismsRequest, ListAuthenticationMechanismsResponse> (HandleListAuthenticationMechanisms)); _requestExecutionInfos.Add(AuthenticationRequests.SelectAuthenticationMechanism, BuildRequestExecutionInfo <AuthenticationSubsystem, SelectAuthenticationMechanismsRequest, SelectAuthenticationMechanismsResponse> (HandleSelectAuthenticationMechanismsRequest)); _requestExecutionInfos.Add(AuthenticationRequests.Authenticate, BuildRequestExecutionInfo <AuthenticationSubsystem, AuthenticateRequest, AuthenticateResponse> (HandleAuthenticateRequest)); }
public TPMSubsystem(EndpointContext context, IConnectionsConfiguration config) : base(context, config) { if (typeof(ServerContext).IsAssignableFrom(context.GetType()) == false) { throw new ArgumentException("TpmSubsystem requires a ServerContext"); } _requestExecutionInfos.Add(TPMRequestEnum.TPMRequest, BuildRequestExecutionInfo <TPMSubsystem, TPMRequest, TPMResponse> (HandleTPMRequest)); _requestExecutionInfos.Add(TPMRequestEnum.ListTPMDevices, BuildRequestExecutionInfo <TPMSubsystem, ListTPMsRequest, ListTPMsResponse> (HandleListTPMsRequest)); _requestExecutionInfos.Add(TPMRequestEnum.SelectTPMDevice, BuildRequestExecutionInfo <TPMSubsystem, SelectTPMRequest, SelectTPMResponse> (HandleSelectTPMRequest)); _requestExecutionInfos.Add(TPMRequestEnum.KeyInfo, BuildRequestExecutionInfo <TPMSubsystem, KeyInfoRequest, KeyInfoResponse> (HandleKeyInfoRequest)); }
public ServerContext(FrontEndConnection connection, PacketTransmitter packetTransmitter, IConnectionsConfiguration connectionConfig, AccessControlList acl, IDictionary<string, TPMContext> tpmContexts) : base(connection, packetTransmitter) { _accessControlList = acl; _tpmContexts = tpmContexts; RegisterSubsystem (new DebugSubsystem (this, connectionConfig)); RegisterSubsystem (new AuthenticationSubsystem (this, connectionConfig)); RegisterSubsystem (new TPMSubsystem (this, connectionConfig)); _configured = true; _configuredEvent.Set (); }
/// <summary> /// Creates a ServerContext for the specified connection /// </summary> public static ServerContext CreateServerEndpointContext(FrontEndConnection connection, IConnectionsConfiguration connectionConfig, AccessControlList acl, IDictionary<string, TPMContext> tpmContexts) { PacketTransmitter packetTransmitter = new PacketTransmitter(connection); ServerContext ctx = new ServerContext(connection, packetTransmitter, connectionConfig, acl, tpmContexts); packetTransmitter.StartTransmitting(); return ctx; }
public BaseServerSubsystem(EndpointContext context, IConnectionsConfiguration config) : base(context) { _config = config; }
public ServerContext(FrontEndConnection connection, PacketTransmitter packetTransmitter, IConnectionsConfiguration connectionConfig, AccessControlList acl, IDictionary <string, TPMContext> tpmContexts) : base(connection, packetTransmitter) { _accessControlList = acl; _tpmContexts = tpmContexts; RegisterSubsystem(new DebugSubsystem(this, connectionConfig)); RegisterSubsystem(new AuthenticationSubsystem(this, connectionConfig)); RegisterSubsystem(new TPMSubsystem(this, connectionConfig)); _configured = true; _configuredEvent.Set(); }
/// <summary> /// Creates a ServerContext for the specified connection /// </summary> public static ServerContext CreateServerEndpointContext(FrontEndConnection connection, IConnectionsConfiguration connectionConfig, AccessControlList acl, IDictionary <string, TPMContext> tpmContexts) { PacketTransmitter packetTransmitter = new PacketTransmitter(connection); ServerContext ctx = new ServerContext(connection, packetTransmitter, connectionConfig, acl, tpmContexts); packetTransmitter.StartTransmitting(); return(ctx); }