Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
duniter
Commits
09c25b81
Commit
09c25b81
authored
12 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Now pks/add accepts files as entries
parent
173cfa2b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/jpgp.js
+11
-5
11 additions, 5 deletions
lib/jpgp.js
lib/pks.js
+73
-14
73 additions, 14 deletions
lib/pks.js
views/pks/add.ejs
+5
-0
5 additions, 0 deletions
views/pks/add.ejs
with
89 additions
and
19 deletions
lib/jpgp.js
+
11
−
5
View file @
09c25b81
...
@@ -56,19 +56,25 @@ function JPGP() {
...
@@ -56,19 +56,25 @@ function JPGP() {
}
}
function
command
(
c
,
args
,
callback
)
{
function
command
(
c
,
args
,
callback
)
{
var
argsStr
=
"
-
"
+
c
;
var
argsStr
=
"
"
;
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
)
{
argsStr
+=
"
-
"
+
args
[
i
].
opt
;
argsStr
+=
"
-
"
+
args
[
i
].
opt
;
if
(
args
[
i
].
value
){
if
(
args
[
i
].
value
){
argsStr
+=
"
"
+
args
[
i
].
value
;
argsStr
+=
"
"
+
args
[
i
].
value
;
}
}
}
}
call
(
argsStr
,
callback
);
call
(
c
,
argsStr
,
callback
);
}
}
function
call
(
args
,
callback
)
{
function
call
(
c
,
args
,
callback
)
{
var
cmd
=
'
java -jar
'
+
JPGP_JAR
+
'
'
+
args
;
var
cmd
=
'
java -jar
'
+
JPGP_JAR
+
'
-
'
+
c
+
args
;
exec
(
cmd
,
callback
);
var
start
=
new
Date
();
exec
(
cmd
,
function
(
err
,
stdout
,
stderr
)
{
var
end
=
new
Date
();
var
diff
=
end
.
getTime
()
-
start
.
getTime
();
console
.
log
(
"
jpgp -
"
+
c
,
diff
+
"
ms
"
);
callback
(
err
,
stdout
,
stderr
);
});
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/pks.js
+
73
−
14
View file @
09c25b81
...
@@ -57,21 +57,83 @@ module.exports.add.get = function (req, res) {
...
@@ -57,21 +57,83 @@ module.exports.add.get = function (req, res) {
res
.
render
(
'
../views/pks/add.ejs
'
);
res
.
render
(
'
../views/pks/add.ejs
'
);
};
};
module
.
exports
.
add
.
post
=
function
(
req
,
res
)
{
function
getAAMessage
(
keytext
,
callback
)
{
if
(
req
.
body
&&
req
.
body
.
keytext
&&
req
.
body
.
keysign
){
if
(
keytext
){
var
extractPK
=
req
.
body
.
keytext
.
trim
().
match
(
/
(
-----BEGIN PGP
[\s\S]
*-----END PGP.*-----
)
/
);
var
extractPK
=
keytext
.
trim
().
match
(
/
(
-----BEGIN PGP
[\s\S]
*-----END PGP.*-----
)
/
);
var
extractSIG
=
req
.
body
.
keysign
.
trim
().
match
(
/
(
-----BEGIN PGP
[\s\S]
*-----END PGP.*-----
)
/
);
if
(
extractPK
&&
extractPK
.
length
>
1
){
if
(
extractPK
&&
extractPK
.
length
>
1
&&
extractSIG
&&
extractSIG
.
length
>
1
){
var
asciiArmored
=
extractPK
[
1
];
var
asciiArmored
=
extractPK
[
1
];
var
signature
=
extractSIG
[
1
];
callback
(
null
,
asciiArmored
);
}
else
{
callback
(
"
Not a PGP message.
"
);
}
}
else
{
callback
(
"
keytext HTTP param is null.
"
);
}
}
function
getAsciiArmoredMessages
(
body
,
files
,
callback
)
{
console
.
log
(
JSON
.
stringify
(
body
),
JSON
.
stringify
(
files
));
var
keytext
=
body
.
keytext
||
(
files
?
files
.
keytext
:
""
);
var
keysign
=
body
.
keysign
||
(
files
?
files
.
keysign
:
""
);
var
aaPubkey
,
aaSignature
;
async
.
parallel
({
one
:
function
(
done
){
if
(
keytext
&&
keytext
.
path
){
fs
.
readFile
(
keytext
.
path
,
{
encoding
:
"
utf8
"
},
function
(
err
,
data
)
{
keytext
=
data
;
done
(
err
);
});
}
else
done
();
},
two
:
function
(
done
){
if
(
keysign
&&
keysign
.
path
){
fs
.
readFile
(
keysign
.
path
,
{
encoding
:
"
utf8
"
},
function
(
err
,
data
)
{
keysign
=
data
;
done
(
err
);
});
}
else
done
();
}
},
function
(
err
)
{
if
(
err
){
callback
(
err
);
return
;
}
async
.
parallel
({
one
:
function
(
done
){
getAAMessage
(
keytext
,
function
(
err
,
data
)
{
aaPubkey
=
data
;
done
(
err
);
});
},
two
:
function
(
done
){
getAAMessage
(
keysign
,
function
(
err
,
data
)
{
aaSignature
=
data
;
done
(
err
);
});
}
},
function
(
err
)
{
callback
(
err
,
aaPubkey
,
aaSignature
);
});
});
}
module
.
exports
.
add
.
post
=
function
(
req
,
res
)
{
getAsciiArmoredMessages
(
req
.
body
,
req
.
files
,
function
(
err
,
aaPubkey
,
aaSignature
)
{
if
(
!
err
){
var
PublicKey
=
req
.
models
.
PublicKey
;
var
PublicKey
=
req
.
models
.
PublicKey
;
var
pubKeys
=
[];
var
pubKeys
=
[];
PublicKey
.
verify
(
a
sciiArmored
,
s
ignature
,
function
(
err
)
{
PublicKey
.
verify
(
a
aPubkey
,
aaS
ignature
,
function
(
err
)
{
if
(
!
err
){
if
(
!
err
){
pubKeys
.
push
(
new
PublicKey
({
raw
:
a
sciiArmored
}));
pubKeys
.
push
(
new
PublicKey
({
raw
:
a
aPubkey
}));
async
.
each
(
pubKeys
,
processRawKey
,
function
(
err
)
{
async
.
each
(
pubKeys
,
processRawKey
,
function
(
err
)
{
if
(
!
err
){
if
(
!
err
){
// Now has entity from a
sciiArmored
// Now has entity from a
aPubkey
async
.
each
(
pubKeys
,
function
(
pubkey
,
done
)
{
async
.
each
(
pubKeys
,
function
(
pubkey
,
done
)
{
var
now
=
new
Date
();
var
now
=
new
Date
();
PublicKey
.
count
({
fingerprint
:
pubkey
.
fingerprint
},
function
(
err
,
count
)
{
PublicKey
.
count
({
fingerprint
:
pubkey
.
fingerprint
},
function
(
err
,
count
)
{
...
@@ -125,9 +187,6 @@ module.exports.add.post = function (req, res) {
...
@@ -125,9 +187,6 @@ module.exports.add.post = function (req, res) {
});
});
}
}
else
else
res
.
send
(
400
,
'
Not a OpenPGP key.
'
);
res
.
send
(
400
,
'
Not a OpenPGP data:
'
+
err
);
}
});
else
{
res
.
send
(
400
,
'
No data sent.
'
);
}
};
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
views/pks/add.ejs
+
5
−
0
View file @
09c25b81
...
@@ -12,5 +12,10 @@
...
@@ -12,5 +12,10 @@
<textarea
name=
"keysign"
id=
"keysign"
cols=
"80"
rows=
"45"
></textarea>
<textarea
name=
"keysign"
id=
"keysign"
cols=
"80"
rows=
"45"
></textarea>
<input
type=
"submit"
>
<input
type=
"submit"
>
</form>
</form>
<form
action=
"/pks/add"
method=
"POST"
enctype=
"multipart/form-data"
>
<input
type=
"file"
name=
"keytext"
>
<input
type=
"file"
name=
"keysign"
>
<input
type=
"submit"
>
</form>
</body>
</body>
</html>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment