Skip to content

Commit a9c0035

Browse files
committed
Inital commit of dds-hashcode fork
0 parents  commit a9c0035

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+41565
-0
lines changed

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This is the example web application that demonstrates how to handle hashcode containers together with hashcode
2+
PHP library and DigiDocService.
3+
4+
Copyright (C) 2015 AS Sertifitseerimiskeskus
5+
6+
LICENSE:
7+
8+
This library is free software; you can redistribute it
9+
and/or modify it under the terms of the GNU Lesser General
10+
Public License as published by the Free Software Foundation;
11+
either version 2.1 of the License, or (at your option) any
12+
later version.
13+
14+
This library is distributed in the hope that it will be useful,
15+
but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
Lesser General Public License for more details.
18+
19+
You should have received a copy of the GNU Lesser General Public
20+
License along with this library; if not, write to the Free Software
21+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# DDS Hashcode Sample Web Application
2+
3+
### Features
4+
5+
* Signing existing DDOC and BDOC files with Mobile-ID and ID-card
6+
* Creating new DDOC and BDOC files and signing them with Mobile-ID or with ID-card
7+
* Removing signatures from containers
8+
* Adding data files to container
9+
* Removing data files from container
10+
11+
In the example folder is the example application of the PHP hashcode library.
12+
It is created to demonstrate the ability of DigiDocService to add signature(with ID card and Mobile ID), remove signature, add data file, remove datafile and do verification of a document without actual datafiles.
13+
14+
* Configuration parameters (for different environments) can be modified in commons/configuration.php file.
15+
* Give permission to write to directory that is set in commons/configuration.php in constant HASHCODE_APP_UPLOAD_DIRECTORY (default is upload/ in example webapp root) for wwwrun user (or any other user under which apache operates).
16+
* Register your ID-card signing certificate in www.openxades.org test-environment: http://www.openxades.org/upload_cert.php
17+
* This application should be run over https, since web signing plugins require https.
18+
19+
* Application does some logging to PHP error log. Log format is '[requestId] [sessionId] message'.
20+
- If the user would like to log all requests and responses to and from DigiDocService then the constant LOG_ALL_DDS_REQUESTS_RESPONSES in commons/configuration.php file should be changed to 'true'.
21+
- If the user would like to turn off logging of the application completely then the constant HASHCODE_APP_LOGGING_ON in commons/configuration.php file should be changed to 'false'.
22+
23+
The following extensions have to be enabled in PHP: php_openssl, php_soap.dll.
24+
25+
The following commands can be used to start the built-in PHP server (since PHP version 5.5):
26+
27+
cd examples
28+
php -S localhost:8000
29+
30+
NOTE: By registering your real Mobile-ID certificates into Test-DigiDocService you can use your own phone number (id-code) to test applications with Mobile-ID support.
31+
Registration can be done on this page: https://www.openxades.org/MIDCertsReg/

VagrantFile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5+
$fix_vmware_tools_script = <<SCRIPT
6+
sed -i.bak 's/answer AUTO_KMODS_ENABLED_ANSWER no/answer AUTO_KMODS_ENABLED_ANSWER yes/g' /etc/vmware-tools/locations
7+
sed -i 's/answer AUTO_KMODS_ENABLED no/answer AUTO_KMODS_ENABLED yes/g' /etc/vmware-tools/locations
8+
SCRIPT
9+
10+
VAGRANTFILE_API_VERSION = '2'
11+
12+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
13+
config.vm.provision "shell", inline: $fix_vmware_tools_script
14+
15+
# Uncomment when using virtualbox provider
16+
# config.vm.box = 'ubuntu/vivid64'
17+
config.vm.network 'private_network', ip: '10.33.33.33'
18+
19+
# config.ssh.user = 'root'
20+
# config.ssh.password = 'vagrant'
21+
# config.ssh.insert_key = true
22+
23+
# Uncomment when using VMWare Fusion
24+
config.vm.box = 'boxcutter/ubuntu1504'
25+
config.vm.provider 'virtualbox' do |v|
26+
v.name = 'skphp'
27+
end
28+
29+
# Place SK Hashcode Sample application under /apps directory
30+
config.vm.synced_folder '.', '/apps', create: true, disabled: false
31+
32+
# Configuration files for Nginx and PHP Built-in Server Upstart script
33+
config.vm.synced_folder './server-config', '/home/vagrant/config', create: true, disabled: false
34+
35+
# Make sure Ansible is installed before start vagrant first time
36+
# config.vm.provision 'ansible', run: 'always' do |ansible|
37+
config.vm.provision 'ansible' do |ansible|
38+
ansible.playbook = './ansible/setup.yml'
39+
ansible.verbose = 'v'
40+
ansible.limit = 'all'
41+
ansible.sudo = true
42+
ansible.host_key_checking = false
43+
ansible.extra_vars = {
44+
ansible_ssh_user: 'vagrant',
45+
ansible_connection: 'ssh',
46+
ansible_ssh_args: '-o ForwardAgent=yes'
47+
}
48+
end
49+
end

ansible/setup.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
- hosts: all
3+
user: root
4+
sudo: yes
5+
vars:
6+
upload_directory: /tmp/dds/upload
7+
nginx_default: /etc/nginx/sites-enabled/default
8+
xdebug_config: /etc/php5/fpm/conf.d/20-xdebug.ini
9+
10+
tasks:
11+
- name: Add NodeJS PPA repository
12+
shell: curl -sL https://deb.nodesource.com/setup | sudo bash -
13+
14+
- name: update apt cache
15+
apt: update_cache=yes cache_valid_time=3600
16+
17+
- name: upgrade distro
18+
apt: upgrade=yes
19+
20+
- name: Install packages
21+
apt: pkg={{ item }} state=latest
22+
with_items:
23+
- build-essential
24+
- nodejs
25+
- git
26+
- vim
27+
- php5
28+
- php5-fpm
29+
- php5-xdebug
30+
- nginx-full
31+
- python-pip
32+
- curl
33+
- rsync
34+
- zsh
35+
- zsh-doc
36+
37+
- name: Add Oracle Java Repository
38+
apt_repository: repo="ppa:webupd8team/java"
39+
40+
- name: Accept Oracle license
41+
shell: echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
42+
43+
- name: Install Oracle Java
44+
apt: pkg=oracle-java8-installer state=latest update_cache=yes cache_valid_time=3600
45+
46+
- name: Install global npm Packages
47+
npm: name={{ item }} global=yes
48+
with_items:
49+
- bower
50+
- nodemon
51+
- jade
52+
- browserify
53+
- gulp
54+
- yo
55+
56+
- name: Install Docker into servers
57+
shell: wget -qO- https://get.docker.com/ | sh
58+
59+
# Zsh related stuff
60+
- name: Clone oh-my-zsh
61+
git: repo=git://github.com/robbyrussell/oh-my-zsh.git
62+
dest=/home/vagrant/.oh-my-zsh
63+
accept_hostkey=yes
64+
65+
- name: Copy oh-my-zsh for root also
66+
command: cp -fr /home/vagrant/.oh-my-zsh /root/.oh-my-zsh
67+
68+
- name: Create new zsh config from template
69+
command: cp /home/vagrant/.oh-my-zsh/templates/zshrc.zsh-template /home/vagrant/.zshrc
70+
71+
- name: Create new zsh config for root
72+
command: cp /root/.oh-my-zsh/templates/zshrc.zsh-template /root/.zshrc
73+
74+
- name: Set zsh as default shell
75+
user: name={{ item }} shell=/usr/bin/zsh
76+
with_items:
77+
- vagrant
78+
- root
79+
80+
# App setup
81+
- name: Test that system upload path is set
82+
lineinfile: dest=/etc/php5/fpm/pool.d/www.conf
83+
regexp='env\[DDS_SYSTEM_UPLOAD_PATH\]'
84+
line='env[DDS_SYSTEM_UPLOAD_PATH] = '{{ upload_directory }}
85+
86+
- name: Make sure upload directory exists
87+
file: dest={{ upload_directory }} owner=www-data group=www-data state=directory recurse=yes
88+
89+
- name: Set max upload limit in PHP
90+
replace: dest=/etc/php5/fpm/php.ini
91+
regexp='^upload_max_filesize\s=\s[0-9]+M'
92+
replace='upload_max_filesize = 21M'
93+
backup=yes
94+
95+
# Setup Nginx service
96+
- name: Stop Apache2 service if running
97+
service: name=apache2 state=stopped
98+
99+
- name: Add redirect to SSL configuration to Nginx
100+
file: src=/home/vagrant/config/nginx/redirect_config dest=/etc/nginx/sites-enabled/redirect state=link
101+
102+
- name: Check if Nginx default exists
103+
stat: path={{ nginx_default }}
104+
register: default_stat
105+
106+
- name: Remove Nginx default website
107+
file: path={{ nginx_default }} state=absent
108+
when: default_stat.stat.exists
109+
110+
- name: Install PHP app configuration into Nginx
111+
file: src=/home/vagrant/config/nginx/sk_fpm_config dest={{ nginx_default }} state=link
112+
113+
# PHP Configuration
114+
- name: Check if default XDebug configuration exists
115+
stat: path={{ xdebug_config }}
116+
register: xdebug_stat
117+
118+
- name: Remove default XDebug configuration
119+
file: path={{ xdebug_config }} state=absent
120+
when: xdebug_stat.stat.exists
121+
122+
- name: Set new XDebug configuration
123+
file: src=/home/vagrant/config/xdebug/20-xdebug.ini dest={{ xdebug_config }} state=link
124+
125+
- name: Start PHP-FPM service if not running
126+
service: name=php5-fpm state=restarted
127+
128+
- name: Start Nginx service if not running
129+
service: name=nginx state=restarted enabled=yes

bower.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "dds-hashcode",
3+
"version": "1.1.2",
4+
"authors": [
5+
"Mihkel Selgal <[email protected]>"
6+
],
7+
"description": "\"dds-hashcode sample application client side libs'",
8+
"license": "LGPL",
9+
"ignore": [
10+
"**/.*",
11+
"node_modules",
12+
"bower_components",
13+
"test",
14+
"tests"
15+
],
16+
"dependencies": {
17+
"jquery": "~2.1.3",
18+
"bootstrap": "~3.3.4",
19+
"lodash": "~3.5.0",
20+
"hwcrypto": "~0.0.10",
21+
"native-promise-only": "~0.7.6-a"
22+
}
23+
}

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "sk-hashcode",
3+
"description": "hashcode-sample app",
4+
"minimum-stability": "stable",
5+
"license": "proprietary",
6+
"authors": [
7+
{
8+
"name": "SK",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"classmap": ["hashcode-lib/tests", "hashcode-lib/tests/testFiles", "example/app"],
14+
"psr-0": {
15+
"SK\\Digidoc\\": "hashcode-lib/src"
16+
}
17+
},
18+
"require-dev": {
19+
"katzgrau/klogger": "dev-master",
20+
"phpunit/phpunit": "@stable",
21+
"phpdocumentor/phpdocumentor": "dev-master",
22+
"phpmd/phpmd": "@stable"
23+
}
24+
}

example/_README.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
In the example folder is the example application of the PHP hashcode library.
2+
It is created to demonstrate the ability of DigiDocService to add signature(with ID card and Mobile ID), remove signature, add data file, remove datafile and do verification of a document without actual datafiles.
3+
4+
* Configuration parameters (for different environments) can be modified in commons/configuration.php file.
5+
* Give permission to write to directory that is set in commons/configuration.php in constant HASHCODE_APP_UPLOAD_DIRECTORY (default is upload/ in example webapp root) for wwwrun user (or any other user under which apache operates).
6+
* Register your ID-card signing certificate in www.openxades.org test-environment: http://www.openxades.org/upload_cert.php
7+
* This application should be run over https, since web signing plugins require https.
8+
9+
* Application does some logging to PHP error log. Log format is '[requestId] [sessionId] message'.
10+
- If the user would like to log all requests and responses to and from DigiDocService then the constant LOG_ALL_DDS_REQUESTS_RESPONSES in commons/configuration.php file should be changed to 'true'.
11+
- If the user would like to turn off logging of the application completely then the constant HASHCODE_APP_LOGGING_ON in commons/configuration.php file should be changed to 'false'.
12+
13+
The following extensions have to be enabled in PHP: php_openssl, php_soap.dll.
14+
15+
The following commands can be used to start the built-in PHP server (since PHP version 5.5):
16+
17+
cd examples
18+
php -S localhost:8000
19+
20+
NOTE: By registering your real Mobile-ID certificates into Test-DigiDocService you can use your own phone number (id-code) to test applications with Mobile-ID support.
21+
Registration can be done on this page: https://www.openxades.org/MIDCertsReg/
22+

0 commit comments

Comments
 (0)