nuts-foundation/nuts-discovery

View on GitHub
src/main/kotlin/nl/nuts/discovery/store/entity/Signature.kt

Summary

Maintainability
A
30 mins
Test Coverage
/*
 *     Nuts discovery service for Corda network creation
 *     Copyright (C) 2020 Nuts community
 *
 *     This program is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */

package nl.nuts.discovery.store.entity

import net.corda.core.crypto.DigitalSignature
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id

/**
 * Signature part of a SignedNodeInfo
 */
@Entity
class Signature {

    companion object {

        /**
         * Create entity from Corda DigitalSignature
         */
        fun from(digitalSignature: DigitalSignature): Signature {
            return Signature().apply {
                raw = digitalSignature.bytes
            }
        }
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null

    var raw: ByteArray? = null
}