package org.cryptonit.cloud.timestamping;

import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.cryptonit.cloud.ExecutionContext;
import org.cryptonit.cloud.interfaces.TimestampingPolicy;
import org.cryptonit.cloud.interfaces.TimestampingPolicyFactory;

public class PolicyFactory implements TimestampingPolicyFactory {
    ExecutionContext context;

    public PolicyFactory(ExecutionContext context) {
        this.context = context;
    }

    @Override
    public TimestampingPolicy getTimestampingPolicy(String domain) {
        return null;
    }

    @Override
    public TimestampingPolicy getTimestampingPolicy(String domain, ASN1ObjectIdentifier policyId) {
        return null;
    }    

    @Override
    public void addTimestampingPolicy(TimestampingPolicy policy, String domain) throws Exception {
    }

    @Override
    public void addTimestampingPolicy(TimestampingPolicy policy, String domain, ASN1ObjectIdentifier policyId) throws Exception {
    }
}

@@ -36,16 +36,79 @@
 mping;%0A%0A
+import java.sql.CallableStatement;%0Aimport java.sql.Connection;%0A
 import o
@@ -886,154 +886,851 @@
     
-%7D%0A%0A    @Override%0A    public void addTimestampingPolicy(TimestampingPolicy policy, String domain, ASN1ObjectIdentifier policyId) throws Exception %7B
+    Connection c = context.database.getConnection();%0A        CallableStatement cs = c.prepareCall(%22INSERT INTO timestamping_policy(domain, policyId, identityId, created) %22%0A                + %22VALUES (?, NULL, ?, NOW())%22);%0A        cs.setString(1, domain);%0A        cs.setString(2, policy.getIdentity());%0A        cs.execute();%0A    %7D%0A%0A    @Override%0A    public void addTimestampingPolicy(TimestampingPolicy policy, String domain, ASN1ObjectIdentifier policyId) throws Exception %7B%0A        Connection c = context.database.getConnection();%0A        CallableStatement cs = c.prepareCall(%22INSERT INTO timestamping_policy(domain, policyId, identityId, created) %22%0A                + %22VALUES (?, ?, ?, NOW())%22);%0A        cs.setString(1, domain);%0A        cs.setString(2, policyId.toString());%0A        cs.setString(3, policy.getIdentity());%0A        cs.execute();
 %0A   

Implement addTimestampPolicy methods