Skip to content

Commit

Permalink
Refactor Flash support.
Browse files Browse the repository at this point in the history
- Remove autotools based build suport.
- Add npm flash build support.
- Move mod_fsp to flash/.
- Move swf/ to flash/swf/.
- Move policy servers to flash/.
- Update READMEs.
  • Loading branch information
davidlehn authored and dlongley committed Jan 10, 2017
1 parent 39b70fc commit 79bb19e
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 680 deletions.
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
.cproject
.project
.settings
Makefile
TAGS
aclocal.m4
autom4te.cache
build
config.log
config.status
configure
coverage
dist
node_modules
84 changes: 0 additions & 84 deletions Makefile.in

This file was deleted.

53 changes: 11 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Documentation
* [Utilities](#util)
* [Logging](#log)
* [Debugging](#debug)
* [Flash Socket Policy Module](#fsp)
* [Flash Networking Support](#flash)

### Other

Expand Down Expand Up @@ -121,15 +121,8 @@ The core JavaScript has the following requirements:
* npm
* Chrome, Firefox (optional)

If you wish to use special networking features, the following may
additionally be needed:

* General
* Optional: GNU autotools for the build infrastructure if using Flash.
* Optional: Flash
* A pre-built SocketPool.swf is included.
* Adobe Flex 3 SDK to build the Flash socket code.
* http://opensource.adobe.com/wiki/display/flexsdk/
Some special networking features can optionally use a Flash component. See the
[Flash README](./flash/README.md) for details.

### Building for a web browser

Expand Down Expand Up @@ -199,7 +192,9 @@ use.

Testing in a browser uses [webpack][] to combine forge and all tests and then
loading the result in a browser. A simple web server is provided that will
output the URL to load. Unit tests and older legacy tests are provided.
output the HTTP or HTTPS URLs to load. It also will start a simple Flash Policy
Server. Unit tests and older legacy tests are provided. Custom ports can be
used by running `node tests/server.js` manually.

npm install
npm run build
Expand All @@ -215,30 +210,6 @@ down some tests considerably.
npm install
npm run coverage

### Old build system that includes flash support

To build the whole project, including Flash, run the following:

$ ./build-setup
$ make

This will create the SWF and symlink all the JavaScript files. To see
configure options, run `./configure --help`.

### Old test system including flash support

A test server is provided which can be run in TLS mode and non-TLS mode. Use
the --help option to get help for configuring ports. The server will print out
the local URL you can vist to run tests.

Some of the simplier tests should be run with just the non-TLS server::

$ ./tests/server.py

More advanced tests need TLS enabled::

$ ./tests/server.py --tls

Contributing
------------

Expand Down Expand Up @@ -1812,13 +1783,12 @@ __Examples__
// TODO
```

<a name="fsp" />
### Flash Socket Policy Module

Provides an [Apache][] module "mod_fsp" that can serve up a Flash Socket
Policy. See `mod_fsp/README` for more details. This module makes it easy to
modify an [Apache][] server to allow cross domain requests to be made to it.
<a name="flash" />
### Flash Networking Support

The [flash README](./flash/README.md) provides details on rebuilding the
optional Flash component used for networking. It also provides details on
Policy Server support.

Library Background
------------------
Expand Down Expand Up @@ -1846,7 +1816,6 @@ Financial support is welcome and helps contribute to futher development:
[3DES]: http://en.wikipedia.org/wiki/Triple_DES
[AES]: http://en.wikipedia.org/wiki/Advanced_Encryption_Standard
[ASN.1]: http://en.wikipedia.org/wiki/ASN.1
[Apache]: http://httpd.apache.org/
[Browserify]: http://browserify.org/
[CBC]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
[CFB]: http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
Expand Down
7 changes: 0 additions & 7 deletions build-flash.xml

This file was deleted.

46 changes: 0 additions & 46 deletions build-setup

This file was deleted.

48 changes: 48 additions & 0 deletions flash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Forge Flash Support
===================

SocketPool.swf
--------------

Some special networking features can optionally use a Flash component.
Building the output SWF file requires the [Flex SDK][]. A pre-built component
is included: `swf/SocketPool.swf`.

Building the output SWF requires the `mxmlc` tool from the [Flex SDK][]. If
that tools is already installed then look in the `package.json` file for the
commands to rebuild it. If you need the SDK installed, there is a npm module that installs it:

npm install

To build a regular component:

npm run build

Additional debug support can be built in with the following:

npm run build-debug

Policy Server
-------------

Flash support requires the use of a Policy Server.

### Apache Flash Socket Policy Module

[mod_fsp](./mod_fsp) provides an [Apache][] module that can serve up a Flash
Socket Policy. See `mod_fsp/README` for more details. This module makes it easy
to modify an [Apache][] server to allow cross domain requests to be made to it.

### Simple Python Policy Server

`policyserver.py` provides a very simple test policy server.

### Simple Node.js Policy Server

`policyserver.js` provides a very simple test policy server. If a server is
needed for production environments, please use another option such as perhaps
[nodejs_socket_policy_server][].

[Apache]: http://httpd.apache.org/
[Flex SDK]: https://flex.apache.org/
[nodejs_socket_policy_server]: https://github.com/bichinger/nodejs_socket_policy_server
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions flash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "node-forge-flash",
"version": "0.0.0",
"private": true,
"description": "Flash build support for Forge.",
"homepage": "https://github.com/digitalbazaar/forge",
"author": {
"name": "Digital Bazaar, Inc.",
"email": "[email protected]",
"url": "http://digitalbazaar.com/"
},
"devDependencies": {
"flex-sdk": ""
},
"repository": {
"type": "git",
"url": "https://github.com/digitalbazaar/forge"
},
"bugs": {
"url": "https://github.com/digitalbazaar/forge/issues",
"email": "[email protected]"
},
"license": "(BSD-3-Clause OR GPL-2.0)",
"scripts": {
"build": "mxmlc -debug=false -define=CONFIG::debugging,false -define=CONFIG::release,true -compiler.source-path=. -static-link-runtime-shared-libraries -output=swf/SocketPool.swf SocketPool.as",
"build-debug": "mxmlc -debug=true -define=CONFIG::debugging,true -define=CONFIG::release,false -compiler.source-path=. -static-link-runtime-shared-libraries -output=swf/SocketPool.swf SocketPool.as"
}
}
65 changes: 65 additions & 0 deletions flash/policyserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Forge test Flash Policy Server.
*
* @author Dave Longley
* @author David I. Lehn
*
* Copyright (c) 2010-2016 Digital Bazaar, Inc.
*/
const net = require('net');
const program = require('commander');

// The policy file
// NOTE: This format is very strict. Edit with care.
let policyFile =
'<?xml version="1.0"?>' +
'<!DOCTYPE cross-domain-policy' +
' SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">' +
'<cross-domain-policy>' +
'<allow-access-from domain="*" to-ports="*"/>' +
'</cross-domain-policy>\0';

// Simple non-robust policy file server.
// Looks for a request string and returns the policy file.
exports.policyServer = function(port) {
let prefix = '[policy-server] ';
let server = net.createServer((socket) => {
let remoteAddress = socket.remoteAddress + ':' + socket.remotePort;
console.log(prefix + 'new client connection from %s', remoteAddress);

// deal with strings
socket.setEncoding('utf8');

socket.on('data', (d) => {
if(d.indexOf('<policy-file-request/>') === 0) {
console.log(prefix + 'policy file request from: %s', remoteAddress);
socket.write(policyFile);
} else {
console.log(prefix + 'junk request from %s: %j', remoteAddress, d);
}
});
socket.once('close', () => {
console.log(prefix + 'connection from %s closed', remoteAddress);
});
socket.on('error', (err) => {
console.error(
prefix + 'connection %s error: %s', remoteAddress, err.message);
});
}).on('error', (err) => {
throw err;
});
server.listen(port, () => {
console.log(prefix + 'listening: ', server.address());
});
};

if(require.main === module) {
program
//.option('--host [host]',
// 'host to bind to [localhost]')
.option('--policy-port [port]',
'port used to serve policy file [19945]', 19945)
.parse(process.argv);

exports.policyServer(program.policyPort);
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 79bb19e

Please sign in to comment.