Examples of AbderaSecurity


Examples of org.apache.abdera.security.AbderaSecurity

    keyGenerator.init(128);
    SecretKey key = keyGenerator.generateKey();

    // Create the entry to encrypt
    Abdera abdera = new Abdera();
    AbderaSecurity absec = new AbderaSecurity(abdera);
    Factory factory = abdera.getFactory();
   
    Entry entry = factory.newEntry();
    entry.setId("http://example.org/foo/entry");
    entry.setUpdated(new java.util.Date());
    entry.setTitle("This is an entry");
    entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
    entry.addAuthor("James");
    entry.addLink("http://www.example.org");

    // Prepare the encryption options
    Encryption enc = absec.getEncryption();
    EncryptionOptions options = enc.getDefaultEncryptionOptions();
    options.setDataEncryptionKey(key);
   
    // Encrypt the document using the generated key
    Document enc_doc = enc.encrypt(entry.getDocument(), options);
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

  private Document<Element> signDocument(
    Abdera abdera,
    Document<Element> doc)
      throws SecurityException  {
    AbderaSecurity security = new AbderaSecurity(abdera);
    if (signingKey == null || cert == null) return doc; // pass through
    Signature sig = security.getSignature();
    SignatureOptions options = sig.getDefaultSignatureOptions();
    options.setCertificate(cert);
    options.setSigningKey(signingKey);
    if (algorithm != null)
      options.setSigningAlgorithm(algorithm);
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

      ResponseContext response,
      Object arg) {
        super(response);
        this.abdera = abdera;
        this.request = request;
        this.security = new AbderaSecurity(abdera);
        this.arg = arg;
    }
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

 
  public ResponseContext filter(
    RequestContext request,
    FilterChain chain) {

    AbderaSecurity security = new AbderaSecurity(request.getAbdera());
    Signature sig = security.getSignature();
    String method = request.getMethod();
    if (method.equals("POST") || method.equals("PUT")) {
      try {
        Document<Element> doc = request.getDocument();
        boolean valid = sig.verify(doc.getRoot(), null);
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        throws ParseException,
               IOException {
      Document<Element> doc = super.getDocument();
      try {
        if (doc != null) {
          AbderaSecurity security = new AbderaSecurity(getAbdera());
          Encryption enc = security.getEncryption();
          if (enc.isEncrypted(doc)) {
            Object arg = initArg(request);
            EncryptionOptions encoptions = initEncryptionOptions(request,enc,arg);
            doc = enc.decrypt(doc, encoptions);
          }
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        assertNotNull(signingKey);
        assertNotNull(cert);

        // Create the entry to sign
        Abdera abdera = new Abdera();
        AbderaSecurity absec = new AbderaSecurity(abdera);
        Factory factory = abdera.getFactory();

        Entry entry = factory.newEntry();
        entry.setId("http://example.org/foo/entry");
        entry.setUpdated(new java.util.Date());
        entry.setTitle("This is an entry");
        entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
        entry.addAuthor("James");
        entry.addLink("http://www.example.org");

        // Prepare the digital signature options
        Signature sig = absec.getSignature();
        SignatureOptions options = sig.getDefaultSignatureOptions();
        options.setCertificate(cert);
        options.setSigningKey(signingKey);

        // Sign the entry
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        KeyGenerator keyGenerator = KeyGenerator.getInstance(jceAlgorithmName);
        keyGenerator.init(128);
        SecretKey key = keyGenerator.generateKey();

        // Create the entry to encrypt
        AbderaSecurity absec = new AbderaSecurity(abdera);
        Factory factory = abdera.getFactory();

        Entry entry = factory.newEntry();
        entry.setId("http://example.org/foo/entry");
        entry.setUpdated(new java.util.Date());
        entry.setTitle("This is an entry");
        entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
        entry.addAuthor("James");
        entry.addLink("http://www.example.org");

        // Prepare the encryption options
        Encryption enc = absec.getEncryption();
        EncryptionOptions options = enc.getDefaultEncryptionOptions();
        options.setDataEncryptionKey(key);

        // Encrypt the document using the generated key
        Document enc_doc = enc.encrypt(entry.getDocument(), options);
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

    @Test
    public void testSignedResponseFilter() throws Exception {
        ClientResponse resp = client.get("http://localhost:9002/");
        Document<Element> doc = resp.getDocument();
        Element root = doc.getRoot();
        AbderaSecurity security = new AbderaSecurity(abdera);
        Signature sig = security.getSignature();
        assertTrue(sig.isSigned(root));
        assertTrue(sig.verify(root, sig.getDefaultSignatureOptions()));
    }
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        ClientResponse resp = client.post("http://localhost:9002/feed", entry);
        assertNotNull(resp);
        assertEquals(ResponseType.CLIENT_ERROR, resp.getType());

        // Initialize the keystore
        AbderaSecurity security = new AbderaSecurity(abdera);
        KeyStore ks = KeyStore.getInstance(keystoreType);
        assertNotNull(ks);

        InputStream in = DigitalSignatureTest.class.getResourceAsStream(keystoreFile);
        assertNotNull(in);

        ks.load(in, keystorePass.toCharArray());
        PrivateKey signingKey = (PrivateKey)ks.getKey(privateKeyAlias, privateKeyPass.toCharArray());
        X509Certificate cert = (X509Certificate)ks.getCertificate(certificateAlias);
        assertNotNull(signingKey);
        assertNotNull(cert);

        Signature sig = security.getSignature();
        SignatureOptions options = sig.getDefaultSignatureOptions();
        options.setCertificate(cert);
        options.setSigningKey(signingKey);

        // Sign the entry
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        PrivateKey signingKey = (PrivateKey)ks.getKey(privateKeyAlias, privateKeyPass.toCharArray());
        X509Certificate cert = (X509Certificate)ks.getCertificate(certificateAlias);

        // Create the entry to sign
        Abdera abdera = new Abdera();
        AbderaSecurity absec = new AbderaSecurity(abdera);
        Factory factory = abdera.getFactory();

        Entry entry = factory.newEntry();
        entry.setId("http://example.org/foo/entry");
        entry.setUpdated(new java.util.Date());
        entry.setTitle("This is an entry");
        entry.setContentAsXhtml("This <b>is</b> <i>markup</i>");
        entry.addAuthor("James");
        entry.addLink("http://www.example.org");

        // Prepare the digital signature options
        Signature sig = absec.getSignature();
        SignatureOptions options = sig.getDefaultSignatureOptions();
        options.setCertificate(cert);
        options.setSigningKey(signingKey);

        // Sign the entry
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.