Package org.apache.abdera.model

Examples of org.apache.abdera.model.Entry


         feed.setSubtitle("Feed subtitle");
         feed.setUpdated(new Date());
         feed.addAuthor("James Snell");
         feed.addLink("http://example.com");

         Entry entry = feed.addEntry();
         entry.setId("tag:example.org,2007:/foo/entries/1");
         entry.setTitle("Entry title");
         entry.setUpdated(new Date());
         entry.setPublished(new Date());
         entry.addLink(uri.getRequestUri().toString());

         Customer cust = new Customer("bill");

         JAXBContext ctx = JAXBContext.newInstance(Customer.class);
         StringWriter writer = new StringWriter();
         ctx.createMarshaller().marshal(cust, writer);
         entry.setContent(writer.toString(), "application/xml");
         return feed;

      }
View Full Code Here


      @GET
      @Path("entry")
      @Produces(MediaType.APPLICATION_ATOM_XML)
      public Entry getEntry(@Context UriInfo uri) throws Exception
      {
         Entry entry = abdera.getFactory().newEntry();
         entry.setId("tag:example.org,2007:/foo/entries/1");
         entry.setTitle("Entry title");
         entry.setUpdated(new Date());
         entry.setPublished(new Date());
         entry.addLink(uri.getRequestUri().toString());

         Customer cust = new Customer("bill");

         JAXBContext ctx = JAXBContext.newInstance(Customer.class);
         StringWriter writer = new StringWriter();
         ctx.createMarshaller().marshal(cust, writer);
         entry.setContent(writer.toString(), "application/xml");
         return entry;

      }
View Full Code Here

    // 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
    entry = sig.sign(entry, options);
    assertNotNull(
      entry.getFirstChild(
        new QName(
          "http://www.w3.org/2000/09/xmldsig#",
          "Signature")));
     
    X509Certificate[] certs = sig.getValidSignatureCertificates(entry, options);
    assertNotNull(certs);
    assertEquals(certs.length, 1);
    assertEquals(certs[0].getSubjectDN().getName(), "CN=James M Snell, OU=WebAhead, O=IBM, L=Hanford, ST=California, C=US");
   
    // Check the round trip
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    entry.writeTo(out); // do not use the pretty writer, it will break the signature
    ByteArrayInputStream bais = new ByteArrayInputStream(out.toByteArray());
    Document<Entry> entry_doc = abdera.getParser().parse(bais);
    entry = entry_doc.getRoot();
    assertTrue(sig.verify(entry, null))// the signature better still be valid
   
    entry.setTitle("Change the title");
   
    assertFalse(sig.verify(entry, null)); // the signature better be invalid
   
  }
View Full Code Here

    // 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
    entry = sig.sign(entry, options);
    assertNotNull(
      entry.getFirstChild(
        new QName(
          "http://www.w3.org/2000/09/xmldsig#",
          "Signature")));

    // Verify the signature with Verisign's "Signed Ping" interop endpoint
View Full Code Here

    // 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);
   
    assertEquals(
      enc_doc.getRoot().getQName(),
      new QName(
        "http://www.w3.org/2001/04/xmlenc#",
View Full Code Here

  public static void testSection2BriefEntry() throws Exception {
    //http://feedvalidator.org/testcases/atom/2/brief-entry-noerror.xml
    IRI uri = baseURI.resolve("2/brief-entry-noerror.xml");
    Document<Entry> doc = get(uri);
    assertNotNull(doc);
    Entry entry = doc.getRoot();
    assertNotNull(entry);
    assertNotNull(entry.getTitleElement());
    assertEquals(entry.getLinks(Link.REL_ALTERNATE).size(), 1);
    assertNotNull(entry.getIdElement());
    assertNotNull(entry.getIdElement().getValue());
    assertNotNull(entry.getUpdatedElement());
    assertNotNull(entry.getUpdatedElement().getValue());
    assertNotNull(entry.getUpdatedElement().getValue().getDate());
    assertNotNull(entry.getSummaryElement());
    assertEquals(entry.getSummaryElement().getTextType(), Text.Type.TEXT);
    assertNotNull(entry.getAuthor());
    assertEquals(entry.getAuthor().getName(), "John Doe");
  }
View Full Code Here

    IRI uri = baseURI.resolve("2/infoset-empty1.xml");
    Document<Feed> doc = get(uri);
    assertNotNull(doc);
    Feed feed = doc.getRoot();
    assertNotNull(feed);
    Entry entry = feed.getEntries().get(0);
    assertEquals(entry.getTitle(),"");
  }
View Full Code Here

    IRI uri = baseURI.resolve("2/infoset-empty2.xml");
    Document<Feed> doc = get(uri);
    assertNotNull(doc);
    Feed feed = doc.getRoot();
    assertNotNull(feed);
    Entry entry = feed.getEntries().get(0);
    assertEquals(entry.getTitle(),"");
  }
View Full Code Here

  public static void testSection2XmlBaseElemEqDoc() throws Exception {
    //http://feedvalidator.org/testcases/atom/2/xml-base-elem-eq-doc.xml
    IRI uri = baseURI.resolve("2/xml-base-elem-eq-doc.xml");
    Document<Feed> doc = get(uri);
    assertNotNull(doc);
    Entry entry = doc.getRoot().getEntries().get(0);
    assertEquals(entry.getAlternateLink().getResolvedHref(), new IRI("http://www.feedvalidator.org/2003/12/13/atom03"));
  }
View Full Code Here

  public static void testSection3112InvalidHtml() throws Exception {
    //http://feedvalidator.org/testcases/atom/3.1.1.2/invalid_html.xml
    IRI uri = baseURI.resolve("3.1.1.2/invalid_html.xml");
    Document<Feed> doc = get(uri);
    assertNotNull(doc);
    Entry entry = doc.getRoot().getEntries().get(0);
    assertEquals(entry.getSummary().trim(), "<a");
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.model.Entry

Copyright © 2018 www.massapicom. 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.