Package org.apache.abdera

Examples of org.apache.abdera.Abdera


        certificateAlias);
    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
    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");
   
View Full Code Here


        certificateAlias);
    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
    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
    Client client = new CommonsClient();
    RequestOptions reqoptions = client.getDefaultRequestOptions();
    reqoptions.setContentType("application/xml");
    BaseRequestEntity bre = new BaseRequestEntity(entry,false);
    ClientResponse response = client.post(
      "http://verisignlabs.com/tg/verify",
      bre, reqoptions);
    assertEquals(response.getStatus(),200);
    Document<Element> result = response.getDocument();
   
    XPath xpath = abdera.getXPath();
    assertTrue(
      xpath.booleanValueOf(
        "/Result/SignatureVerifies[text()='true']",
        result));
View Full Code Here

        KeyGenerator.getInstance(jceAlgorithmName);
    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");
View Full Code Here

    if (INSTANCE == null) INSTANCE = new ServiceManager();
    return INSTANCE;
  }
 
  public static synchronized Abdera getAbdera() {
    if (abdera == null) abdera = new Abdera();
    return abdera;
  }
View Full Code Here

    return abdera;
  }
 
  public ServiceContext newServiceContext(
    Map<String,String> properties) {
    Abdera abdera = getAbdera();
    String instance = properties.get(SERVICE_CONTEXT);
    ServiceContext context =
      (ServiceContext) ServiceUtil.newInstance(
        SERVICE_CONTEXT,
        (instance != null) ?
View Full Code Here

  private final Abdera abdera;
  private final Encryption encryption;
  private final Signature signature;
 
  public AbderaSecurity() {
    this(new Abdera());
  }
View Full Code Here

    this.encryption = newEncryption();
    this.signature = newSignature();
  }
 
  public AbderaSecurity(AbderaConfiguration config) {
    this(new Abdera(config));
  }
View Full Code Here

  private final Abdera abdera;
  private final Map<String,NamedWriter> writers;
 
  public FOMWriterFactory() {
    this(new Abdera());
  }
View Full Code Here

    if (!org.apache.xml.security.Init.isInitialized())
      org.apache.xml.security.Init.init();
  }

  public XmlSignature() {
    super(new Abdera());
  }
View Full Code Here

  private final Abdera abdera;
  private final Map<String,NamedParser> parsers;
 
  public FOMParserFactory() {
    this(new Abdera());
  }
View Full Code Here

TOP

Related Classes of org.apache.abdera.Abdera

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.