Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
f700411f
Commit
f700411f
authored
7 years ago
by
Pavel Kácha
Browse files
Options
Downloads
Patches
Plain Diff
Fixed grave omission - switched object order
parent
ca9a3ffc
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
warden3/contrib/warden_ra/warden_ra.py
+72
-72
72 additions, 72 deletions
warden3/contrib/warden_ra/warden_ra.py
with
72 additions
and
72 deletions
warden3/contrib/warden_ra/warden_ra.py
+
72
−
72
View file @
f700411f
...
...
@@ -69,78 +69,6 @@ class Client(object):
return
str
(
self
)
+
(
str
(
self
.
opaque
)
if
self
.
opaque
and
verbose
else
""
)
class
EjbcaRegistry
(
OpenSSLRegistry
):
status_ejbca_to_str
=
{
ejbcaws
.
STATUS_NEW
:
"
Issuable
"
,
ejbcaws
.
STATUS_GENERATED
:
"
Passive
"
,
ejbcaws
.
STATUS_INITIALIZED
:
"
New
"
,
ejbcaws
.
STATUS_HISTORICAL
:
"
Disabled
"
}
status_str_to_ejbca
=
dict
((
v
,
k
)
for
k
,
v
in
status_ejbca_to_str
.
items
())
def
__init__
(
self
,
log
,
url
,
cert
=
None
,
key
=
None
,
ca_name
=
""
,
certificate_profile_name
=
""
,
end_entity_profile_name
=
""
,
subject_dn_template
=
"
%s
"
,
username_suffix
=
""
):
self
.
log
=
log
self
.
ejbca
=
ejbcaws
.
Ejbca
(
url
,
cert
,
key
)
self
.
ca_name
=
ca_name
self
.
certificate_profile_name
=
certificate_profile_name
self
.
end_entity_profile_name
=
end_entity_profile_name
self
.
subject_dn_template
=
subject_dn_template
self
.
username_suffix
=
username_suffix
def
client_data
(
self
,
ejbca_data
):
ejbca_username
=
ejbca_data
[
"
username
"
]
username
=
ejbca_username
[:
-
len
(
self
.
username_suffix
)]
if
ejbca_username
.
endswith
(
self
.
username_suffix
)
else
ejbca_username
admins
=
[
u
if
not
u
.
startswith
(
"
RFC822NAME
"
)
else
u
[
11
:]
for
u
in
ejbca_data
[
"
subjectAltName
"
].
split
(
"
,
"
)]
status
=
self
.
status_ejbca_to_str
.
get
(
ejbca_data
[
"
status
"
],
"
Other
"
)
return
username
,
admins
,
status
,
None
,
ejbca_data
def
get_clients
(
self
):
return
[
Client
(
*
self
.
client_data
(
u
))
for
u
in
self
.
ejbca
.
get_users
()]
def
get_client
(
self
,
name
):
users
=
self
.
ejbca
.
find_user
(
ejbcaws
.
MATCH_WITH_USERNAME
,
ejbcaws
.
MATCH_TYPE_EQUALS
,
name
+
self
.
username_suffix
)
if
len
(
users
)
>
1
:
raise
LookupError
(
"
%d users %s found (more than one?!)
"
%
(
len
(
users
),
name
))
if
not
users
:
return
None
return
Client
(
*
self
.
client_data
(
users
[
0
]))
def
save_client
(
self
,
client
):
edata
=
client
.
opaque
or
dict
(
caName
=
self
.
ca_name
,
certificateProfileName
=
self
.
certificate_profile_name
,
endEntityProfileName
=
self
.
end_entity_profile_name
,
keyRecoverable
=
False
,
sendNotification
=
False
,
tokenType
=
ejbcaws
.
TOKEN_TYPE_USERGENERATED
,
password
=
""
.
join
((
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
dummy
in
range
(
16
))),
clearPwd
=
True
,
username
=
client
.
name
+
self
.
username_suffix
,
subjectDN
=
self
.
subject_dn_template
%
client
.
name
)
edata
[
"
subjectAltName
"
]
=
"
,
"
.
join
((
"
RFC822NAME=%s
"
%
a
for
a
in
client
.
admins
))
edata
[
"
status
"
]
=
self
.
status_str_to_ejbca
.
get
(
client
.
status
,
edata
[
"
status
"
])
if
client
.
pwd
:
edata
[
"
password
"
]
=
client
.
pwd
edata
[
"
clearPwd
"
]
=
True
self
.
ejbca
.
edit_user
(
edata
)
def
get_certs
(
self
,
client
):
return
self
.
ejbca
.
find_certs
(
client
.
opaque
[
"
username
"
],
validOnly
=
False
)
def
new_cert
(
self
,
client
,
csr
,
pwd
):
cert
=
self
.
ejbca
.
pkcs10_request
(
client
.
opaque
[
"
username
"
],
pwd
,
csr
,
0
,
ejbcaws
.
RESPONSETYPE_CERTIFICATE
)
return
cert
def
__str__
(
self
):
return
self
.
ejbca
.
get_version
()
class
OpenSSLRegistry
(
object
):
def
__init__
(
self
,
log
,
base_dir
,
...
...
@@ -251,6 +179,78 @@ class OpenSSLRegistry(object):
return
"
%s<%s>
"
%
(
type
(
self
).
__name__
,
self
.
base_dir
)
class
EjbcaRegistry
(
OpenSSLRegistry
):
status_ejbca_to_str
=
{
ejbcaws
.
STATUS_NEW
:
"
Issuable
"
,
ejbcaws
.
STATUS_GENERATED
:
"
Passive
"
,
ejbcaws
.
STATUS_INITIALIZED
:
"
New
"
,
ejbcaws
.
STATUS_HISTORICAL
:
"
Disabled
"
}
status_str_to_ejbca
=
dict
((
v
,
k
)
for
k
,
v
in
status_ejbca_to_str
.
items
())
def
__init__
(
self
,
log
,
url
,
cert
=
None
,
key
=
None
,
ca_name
=
""
,
certificate_profile_name
=
""
,
end_entity_profile_name
=
""
,
subject_dn_template
=
"
%s
"
,
username_suffix
=
""
):
self
.
log
=
log
self
.
ejbca
=
ejbcaws
.
Ejbca
(
url
,
cert
,
key
)
self
.
ca_name
=
ca_name
self
.
certificate_profile_name
=
certificate_profile_name
self
.
end_entity_profile_name
=
end_entity_profile_name
self
.
subject_dn_template
=
subject_dn_template
self
.
username_suffix
=
username_suffix
def
client_data
(
self
,
ejbca_data
):
ejbca_username
=
ejbca_data
[
"
username
"
]
username
=
ejbca_username
[:
-
len
(
self
.
username_suffix
)]
if
ejbca_username
.
endswith
(
self
.
username_suffix
)
else
ejbca_username
admins
=
[
u
if
not
u
.
startswith
(
"
RFC822NAME
"
)
else
u
[
11
:]
for
u
in
ejbca_data
[
"
subjectAltName
"
].
split
(
"
,
"
)]
status
=
self
.
status_ejbca_to_str
.
get
(
ejbca_data
[
"
status
"
],
"
Other
"
)
return
username
,
admins
,
status
,
None
,
ejbca_data
def
get_clients
(
self
):
return
[
Client
(
*
self
.
client_data
(
u
))
for
u
in
self
.
ejbca
.
get_users
()]
def
get_client
(
self
,
name
):
users
=
self
.
ejbca
.
find_user
(
ejbcaws
.
MATCH_WITH_USERNAME
,
ejbcaws
.
MATCH_TYPE_EQUALS
,
name
+
self
.
username_suffix
)
if
len
(
users
)
>
1
:
raise
LookupError
(
"
%d users %s found (more than one?!)
"
%
(
len
(
users
),
name
))
if
not
users
:
return
None
return
Client
(
*
self
.
client_data
(
users
[
0
]))
def
save_client
(
self
,
client
):
edata
=
client
.
opaque
or
dict
(
caName
=
self
.
ca_name
,
certificateProfileName
=
self
.
certificate_profile_name
,
endEntityProfileName
=
self
.
end_entity_profile_name
,
keyRecoverable
=
False
,
sendNotification
=
False
,
tokenType
=
ejbcaws
.
TOKEN_TYPE_USERGENERATED
,
password
=
""
.
join
((
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
dummy
in
range
(
16
))),
clearPwd
=
True
,
username
=
client
.
name
+
self
.
username_suffix
,
subjectDN
=
self
.
subject_dn_template
%
client
.
name
)
edata
[
"
subjectAltName
"
]
=
"
,
"
.
join
((
"
RFC822NAME=%s
"
%
a
for
a
in
client
.
admins
))
edata
[
"
status
"
]
=
self
.
status_str_to_ejbca
.
get
(
client
.
status
,
edata
[
"
status
"
])
if
client
.
pwd
:
edata
[
"
password
"
]
=
client
.
pwd
edata
[
"
clearPwd
"
]
=
True
self
.
ejbca
.
edit_user
(
edata
)
def
get_certs
(
self
,
client
):
return
self
.
ejbca
.
find_certs
(
client
.
opaque
[
"
username
"
],
validOnly
=
False
)
def
new_cert
(
self
,
client
,
csr
,
pwd
):
cert
=
self
.
ejbca
.
pkcs10_request
(
client
.
opaque
[
"
username
"
],
pwd
,
csr
,
0
,
ejbcaws
.
RESPONSETYPE_CERTIFICATE
)
return
cert
def
__str__
(
self
):
return
self
.
ejbca
.
get_version
()
def
format_cert
(
cert
):
return
(
"
Subject: %s
\n
"
...
...
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