Examples of AbderaSecurity


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

        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

    } catch (Exception e) {
      throw new RuntimeException("The Configured JCE Provider is not available");
    }

    // 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 Diffie-Hellman Key Exchange Session
    // There are two participants in the session, A and B
    // Each has their own DHContext. A creates their context and
    // sends the request key parameters to B.  B uses those parameters
    // to create their context, the returns it's public key
    // back to A.
    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);
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

        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

    if (method.equals("POST") || method.equals("PUT")) {
      BufferedRequestWrapper wrapper =
        new BufferedRequestWrapper((HttpServletRequest) request);
      try {
        Abdera abdera = new Abdera();
        AbderaSecurity absec = new AbderaSecurity(abdera);
        Signature sig = absec.getSignature();
        Document<Element> doc = abdera.getParser().parse(wrapper.getInputStream());
        boolean valid = sig.verify(doc.getRoot(), null);
        if (!valid) {
          ((HttpServletResponse)response).sendError(
            400, Messages.get("VALID.SIGNATURE.REQUIRED"));
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

  implements Filter {

  protected final AbderaSecurity security;
 
  protected SecurityFilter() {
    this.security = new AbderaSecurity(getAbdera());
  }
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.