Examples of Encryption


Examples of org.apache.abdera.security.Encryption

    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);

    enc_doc.writeTo(System.out);
   
    System.out.println("\n\n");
   
    // Decrypt the document using the generated key
    Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

    entry_doc.writeTo(System.out);
   
  }
View Full Code Here

Examples of org.apache.abdera.security.Encryption

          super.writeTo(out,writer);
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        doc = abdera.getParser().parse(in);
      } catch (Exception e) {}
      if (doc != null) { 
        Encryption enc = security.getEncryption();
        EncryptionOptions options = initEncryptionOptions(request,response,enc,arg);
        doc = enc.encrypt(doc, options);
      }
      if (doc != null)
        doc.writeTo(aout);
      else
        throw new RuntimeException(
View Full Code Here

Examples of org.apache.abdera.security.Encryption

               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);
          }
        }
      } catch (Exception e) {}
      return (Document<T>) doc;
    }
View Full Code Here

Examples of org.apache.abdera.security.Encryption

        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);

        assertEquals(new QName("http://www.w3.org/2001/04/xmlenc#", "EncryptedData"), enc_doc.getRoot().getQName());

        // Decrypt the document using the generated key
        Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

        assertTrue(entry_doc.getRoot() instanceof Entry);

        assertEquals("http://example.org/foo/entry", entry_doc.getRoot().getId().toString());
View Full Code Here

Examples of org.apache.abdera.security.Encryption

        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);

        enc_doc.writeTo(System.out);

        System.out.println("\n\n");

        // Decrypt the document using the generated key
        Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

        entry_doc.writeTo(System.out);

    }
View Full Code Here

Examples of org.apache.abdera.security.Encryption

        DHContext context_a = new DHContext();
        DHContext context_b = new DHContext(context_a.getRequestString());
        context_a.setPublicKey(context_b.getResponseString());

        // Prepare the encryption options
        Encryption enc = absec.getEncryption();

        // Encrypt the document using A's DHContext
        EncryptionOptions options = context_a.getEncryptionOptions(enc);
        Document enc_doc = enc.encrypt(entry.getDocument(), options);

        enc_doc.writeTo(System.out);

        System.out.println("\n\n");

        // Decrypt the document using B's DHContext
        options = context_b.getEncryptionOptions(enc);
        Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

        entry_doc.writeTo(System.out);

    }
View Full Code Here

Examples of org.apache.abdera.security.Encryption

            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);
                    }
                }
            } catch (Exception e) {
            }
            return (Document<T>)doc;
View Full Code Here

Examples of org.apache.abdera.security.Encryption

                ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
                doc = abdera.getParser().parse(in);
            } catch (Exception e) {
            }
            if (doc != null) {
                Encryption enc = security.getEncryption();
                EncryptionOptions options = initEncryptionOptions(request, response, enc, arg);
                doc = enc.encrypt(doc, options);
            }
            if (doc != null)
                doc.writeTo(aout);
            else
                throw new RuntimeException("There was an error encrypting the response");
View Full Code Here

Examples of org.apache.abdera.security.Encryption

    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);
   
    assertEquals(
      enc_doc.getRoot().getQName(),
      new QName(
        "http://www.w3.org/2001/04/xmlenc#",
        "EncryptedData"));
   
    // Decrypt the document using the generated key
    Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

    assertTrue(entry_doc.getRoot() instanceof Entry);
   
    assertEquals(
      entry_doc.getRoot().getId().toString(),
View Full Code Here

Examples of org.apache.abdera.security.Encryption

    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);

    enc_doc.writeTo(System.out);
   
    System.out.println("\n\n");
   
    // Decrypt the document using the generated key
    Document<Entry> entry_doc = enc.decrypt(enc_doc, options);

    entry_doc.writeTo(System.out);
   
  }
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.