/// <summary> /// creates the second message to the received first message from the issuer /// </summary> /// <param name="devicePublicKey">if the tokens are hard token protected, this is /// the public key of that device</param> /// <returns>SecondMessage as json string or if there was a failure, an empty string</returns> public string GenerateSecondMessage(GroupElement devicePublicKey = null) { try { LogService.Log(LogService.LogType.Info, "IssuingProver - GenerateSecondMessage called"); // initialize prover protocol ProverProtocolParameters ppp = new ProverProtocolParameters(IP); ppp.Attributes = ByteAttributes = ci.ConvertAttributeListToBase64ByteArray(Attributes); ppp.NumberOfTokens = numberOfTokens; ppp.TokenInformation = ti != null ? ti : null; ppp.ProverInformation = pi; if (devicePublicKey != null) { ppp.DevicePublicKey = devicePublicKey; } prover = ppp.CreateProver(); string secondMessageJson = IP.Serialize <SecondIssuanceMessage>( prover.GenerateSecondMessage(IP.Deserialize <FirstIssuanceMessage>(firstMessageJson))); LogService.Log(LogService.LogType.Info, "IssuingProver - SecondMessage created: " + secondMessageJson); return(secondMessageJson); } catch (Exception e) { LogService.Log(LogService.LogType.Error, "IssuingProver - Error during second message generation.", e); throw new CommunicationException("IssuingProver - Error during second message generation.", e); } }
/// <summary> /// Creates the token out of the received third message /// </summary> /// <param name="thirdMessage">third message as json</param> /// <param name="skipTokenValidation">if the hard token validation should get /// skipped - testing mode only /// </param> public void GenerateTokens(string thirdMessage, bool skipTokenValidation = false) { try { LogService.Log(LogService.LogType.Info, "IssuingProver - GenerateTokens called"); KeyAndToken = prover.GenerateTokens(IP.Deserialize <ThirdIssuanceMessage>(thirdMessage), skipTokenValidation); LogService.Log(LogService.LogType.Info, "IssuingProver - token successfull generated"); } catch (Exception e) { LogService.Log(LogService.LogType.Info, "IssuingProver - Error during token generation.", e); throw new CommunicationException("IssuingProver - Error during token generation.", e); } }