Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alternate-mdx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Trust and Identity Incubator
alternate-mdx
Commits
8c298b0f
Commit
8c298b0f
authored
3 years ago
by
Martin van Es
Browse files
Options
Downloads
Patches
Plain Diff
First commit
parent
fd33fc8a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+7
-0
7 additions, 0 deletions
.gitignore
README.md
+10
-1
10 additions, 1 deletion
README.md
mdsigner.py
+56
-0
56 additions, 0 deletions
mdsigner.py
requirements.txt
+2
-0
2 additions, 0 deletions
requirements.txt
with
75 additions
and
1 deletion
.gitignore
0 → 100644
+
7
−
0
View file @
8c298b0f
# created by virtualenv automatically
bin/
lib/
pyvenv.cfg
meta.crt
meta.key
*.xml
This diff is collapsed.
Click to expand it.
README.md
+
10
−
1
View file @
8c298b0f
# alternate-mdx
# alternate-mdx
Alternate MDX research project
Alternate MDX research project
\ No newline at end of file
## Usage
-
Create python virtualenv
-
Activate virtualenv (
```. bin/activate```
)
-
```pip install -r requirements.txt```
-
Create (self-signed) metadata signing cert (
```meta.crt/meta.key```
)
-
Create output directory (
```mkdir output```
)
-
Download metadata file(s)
-
Run
```./mdsigner <metadata file(s)>```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
mdsigner.py
0 → 100755
+
56
−
0
View file @
8c298b0f
#!/usr/bin/env python
import
sys
import
copy
from
concurrent.futures
import
ThreadPoolExecutor
from
lxml
import
etree
as
ET
from
signxml
import
XMLSigner
,
XMLVerifier
import
hashlib
# import traceback
# Find all IdP's in edugain metadata
idps
=
[]
success
=
0
failed
=
0
maxthreads
=
8
cert
=
open
(
"
meta.crt
"
).
read
()
key
=
open
(
"
meta.key
"
).
read
()
def
sign
(
xml
,
name
):
global
success
,
failed
,
cert
# print("Signer")
try
:
sha1
=
hashlib
.
sha1
()
sha1
.
update
(
name
.
encode
(
'
utf-8
'
))
sha1d
=
sha1
.
hexdigest
()
signed
=
XMLSigner
().
sign
(
xml
,
key
=
key
,
cert
=
cert
)
out
=
ET
.
tostring
(
signed
,
pretty_print
=
True
).
decode
()
# XMLVerifier().verify(out, x509_cert=cert)
with
open
(
f
'
output/
{
sha1d
}
.xml
'
,
'
w
'
)
as
f
:
f
.
write
(
out
)
success
+=
1
except
Exception
as
e
:
print
(
name
)
print
(
f
"
{
e
}
"
)
# traceback.print_exc()
failed
+=
1
with
ThreadPoolExecutor
(
max_workers
=
maxthreads
)
as
executor
:
for
mdfile
in
sys
.
argv
[
1
:]:
tree
=
ET
.
ElementTree
(
file
=
mdfile
)
root
=
tree
.
getroot
()
ns
=
copy
.
deepcopy
(
root
.
nsmap
)
ns
[
'
xml
'
]
=
'
http://www.w3.org/XML/1998/namespace
'
for
idp
in
root
.
findall
(
'
md:EntityDescriptor
'
,
ns
):
entityID
=
idp
.
attrib
.
get
(
'
entityID
'
,
'
none
'
)
if
entityID
not
in
idps
:
idps
.
append
(
entityID
)
executor
.
submit
(
sign
,
idp
,
entityID
)
print
(
f
"
Succeeded:
{
success
}
"
)
print
(
f
"
Failed:
{
failed
}
"
)
This diff is collapsed.
Click to expand it.
requirements.txt
0 → 100644
+
2
−
0
View file @
8c298b0f
lxml
signxml
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