func NewDecryptedMessage(header *segment.MessageHeaderSegment, end *segment.MessageEndSegment, rawMessage []byte) (BankMessage, error) {
	unmarshaler := NewUnmarshaler(rawMessage)
	err := unmarshaler.Unmarshal()
	if err != nil {
		return nil, fmt.Errorf("Malformed decrypted message bytes: %v", err)
	}
	messageAcknowledgement := unmarshaler.SegmentByID("HIRMG").(*segment.MessageAcknowledgement)
	messageAcknowledgement.SetReferencingMessage(header.ReferencingMessage())
	acknowledgements := messageAcknowledgement.Acknowledgements()
	for _, seg := range unmarshaler.SegmentsByID("HIRMS") {
		if segmentAcknowledgement, ok := seg.(*segment.SegmentAcknowledgement); ok {
			acknowledgements = append(acknowledgements, segmentAcknowledgement.Acknowledgements()...)
		} else {
			panic(fmt.Errorf("Error while unmarshaling segments"))
		}
	}
	version, ok := segment.SupportedHBCIVersions[header.HBCIVersion.Val()]
	if !ok {
		return nil, fmt.Errorf("Unsupported HBCI version: %d", header.HBCIVersion.Val())
	}
	message := &decryptedMessage{
		rawMessage:       rawMessage,
		acknowledgements: acknowledgements,
		unmarshaler:      unmarshaler,
		hbciVersion:      version,
	}
	// TODO: set hbci message appropriate, if possible
	message.message = NewBasicMessageWithHeaderAndEnd(header, end, message)
	return message, nil
}
// NewDecryptedMessage creates a new decrypted message from rawMessage
NewDecryptedMessage creates a new decrypted message from rawMessage
// NewDecryptedMessage creates a new decrypted message from rawMessage
func NewDecryptedMessage(header *segment.MessageHeaderSegment, end *segment.MessageEndSegment, rawMessage []byte) (BankMessage, error) {
	unmarshaler := NewUnmarshaler(rawMessage)
	err := unmarshaler.Unmarshal()
	if err != nil {
		return nil, fmt.Errorf("Malformed decrypted message bytes: %v", err)
	}
	messageAcknowledgement := unmarshaler.SegmentByID("HIRMG").(*segment.MessageAcknowledgement)
	messageAcknowledgement.SetReferencingMessage(header.ReferencingMessage())
	acknowledgements := messageAcknowledgement.Acknowledgements()
	for _, seg := range unmarshaler.SegmentsByID("HIRMS") {
		if segmentAcknowledgement, ok := seg.(*segment.SegmentAcknowledgement); ok {
			acknowledgements = append(acknowledgements, segmentAcknowledgement.Acknowledgements()...)
		} else {
			panic(fmt.Errorf("Error while unmarshaling segments"))
		}
	}
	version, ok := segment.SupportedHBCIVersions[header.HBCIVersion.Val()]
	if !ok {
		return nil, fmt.Errorf("Unsupported HBCI version: %d", header.HBCIVersion.Val())
	}
	message := &decryptedMessage{
		rawMessage:       rawMessage,
		acknowledgements: acknowledgements,
		unmarshaler:      unmarshaler,
		hbciVersion:      version,
	}
	message.message = NewBasicMessageWithHeaderAndEnd(header, end, message)
	return message, nil
}
func NewDecryptedMessage ( header * segment . MessageHeaderSegment , end * segment . MessageEndSegment , rawMessage [ ] byte ) ( BankMessage , error ) { unmarshaler := NewUnmarshaler ( rawMessage ) err := unmarshaler . Unmarshal ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } messageAcknowledgement := unmarshaler . SegmentByID ( " " ) . ( * segment . MessageAcknowledgement ) messageAcknowledgement . SetReferencingMessage ( header . ReferencingMessage ( ) ) acknowledgements := messageAcknowledgement . Acknowledgements ( ) for _ , seg := range unmarshaler . SegmentsByID ( " " ) { if segmentAcknowledgement , ok := seg . ( * segment . SegmentAcknowledgement ) ; ok { acknowledgements = append ( acknowledgements , segmentAcknowledgement . Acknowledgements ( ) ... ) } else { panic ( fmt . Errorf ( " " ) ) } } version , ok := segment . SupportedHBCIVersions [ header . HBCIVersion . Val ( ) ] if ! ok { return nil , fmt . Errorf ( " " , header . HBCIVersion . Val ( ) ) } message := & decryptedMessage { rawMessage : rawMessage , acknowledgements : acknowledgements , unmarshaler : unmarshaler , hbciVersion : version , } message . message = NewBasicMessageWithHeaderAndEnd ( header , end , message ) return message , nil }
NewDecryptedMessage creates a new decrypted message from rawMessage
NewDecryptedMessage creates a new decrypted message from rawMessage
// TODO: set hbci message appropriate, if possible