Examples of AbderaSecurity


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

        } 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

        public <T extends Element> Document<T> getDocument(Parser parser, ParserOptions options) 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

    public ResponseContext filter(RequestContext request, FilterChain chain) {
        return new SigningResponseContextWrapper(request.getAbdera(), chain.next(request));
    }

    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

        public EncryptingResponseContext(Abdera abdera, RequestContext request, 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 static final String VALID = "org.apache.abdera.security.util.servlet.SignedRequestFilter.valid";
    public static final String CERTS = "org.apache.abdera.security.util.servlet.SignedRequestFilter.certs";

    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

        // inlining all the steps to help implementors and porters (and
        // debuggers)

        // configure for signing
        Element signedNode, signatureElement, keyInfo;
        AbderaSecurity security = new AbderaSecurity(Abdera.getInstance());
        Signature signer = security.getSignature();

        String feedId = Common.toFeedId(signingKeys.getPublic());
        Feed feed = pull(feedId);
        if (feed == null) {
            feed = Abdera.getInstance().newFeed();
View Full Code Here

Examples of org.apache.abdera.security.AbderaSecurity

                            + Common.fromFeedUrn(feed.getId()) + " : "
                            + Common.toFeedId(publicKey));
        }

        // prep the verifier
        AbderaSecurity security = new AbderaSecurity(Abdera.getInstance());
        Signature signature = security.getSignature();
        SignatureOptions options = signature.getDefaultSignatureOptions();
        options.setSigningAlgorithm("http://www.w3.org/2001/04/xmldsig-more#ecdsa-sha1");
        options.setSignLinks(false);
        options.setPublicKey(publicKey);
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.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
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.