package org.rmatil.sync.persistence.core.dht;

import net.tomp2p.peers.Number160;
import net.tomp2p.utils.Utils;
import org.rmatil.sync.persistence.api.IPathElement;

import java.security.PublicKey;

/**
 * A path element representing data in the DHT
 */
public class DhtPathElement implements IPathElement {

    /**
     * The content key of the path element which should be used
     */
    protected String contentKey;

    /**
     * The domain protection key which should be used
     */
    protected Number160 domainProtectionKey;

    /**
     * @param contentKey A string which gets used as content key in the DHT
     * @param domainProtectionKey A public key which is used for to access and/or modify the path in the DHT
     */
    public DhtPathElement(String contentKey, PublicKey domainProtectionKey) {
        this.contentKey = contentKey;
        this.domainProtectionKey = Utils.makeSHAHash(domainProtectionKey.getEncoded());
    }

    /**
     * Returns the content key
     *
     * @return A string representing the path of the element
     */
    @Override
    public String getPath() {
        return this.contentKey;
    }

    /**
     * Returns the domain protection key which is used
     * to access and/or modify the content in the DHT
     *
     * @return The domain protection key
     */
    public Number160 getDomainProtectionKey() {
        return domainProtectionKey;
    }
}

@@ -181,22 +181,16 @@
 ecurity.
-Public
 Key;%0A%0A/*
@@ -676,12 +676,8 @@
 sed 
-for 
 to a
@@ -678,38 +678,24 @@
 d to access 
-and/or modify 
 the path in 
@@ -759,14 +759,8 @@
 ey, 
-Public
 Key 
@@ -1197,22 +1197,8 @@
 ess 
-and/or modify 
 the 

Use a generic key instead of PublicKey