Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
erp5
Commits
fac4a0ea
Commit
fac4a0ea
authored
Nov 01, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_certificate_authority: Use specific property for store CSR ID
it ensure that property is an integer.
parent
b83079a2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
15 deletions
+109
-15
bt5/erp5_certificate_authority/MixinTemplateItem/portal_components/mixin.erp5.CertificateLoginMixin.py
...tem/portal_components/mixin.erp5.CertificateLoginMixin.py
+9
-9
bt5/erp5_certificate_authority/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
...rtalTypePropertySheetTemplateItem/property_sheet_list.xml
+3
-0
bt5/erp5_certificate_authority/PropertySheetTemplateItem/portal_property_sheets/CaucaseCertificateLogin.xml
...teItem/portal_property_sheets/CaucaseCertificateLogin.xml
+62
-0
bt5/erp5_certificate_authority/PropertySheetTemplateItem/portal_property_sheets/CaucaseCertificateLogin/csr_id_property.xml
...operty_sheets/CaucaseCertificateLogin/csr_id_property.xml
+28
-0
bt5/erp5_certificate_authority/TestTemplateItem/portal_components/test.erp5.testCertificateAuthorityPerson.py
...al_components/test.erp5.testCertificateAuthorityPerson.py
+4
-5
bt5/erp5_certificate_authority/bt/template_portal_type_property_sheet_list
...ate_authority/bt/template_portal_type_property_sheet_list
+2
-1
bt5/erp5_certificate_authority/bt/template_property_sheet_id_list
..._certificate_authority/bt/template_property_sheet_id_list
+1
-0
No files found.
bt5/erp5_certificate_authority/MixinTemplateItem/portal_components/mixin.erp5.CertificateLoginMixin.py
View file @
fac4a0ea
...
@@ -53,11 +53,11 @@ class CertificateLoginMixin:
...
@@ -53,11 +53,11 @@ class CertificateLoginMixin:
certificate_dict
=
{
certificate_dict
=
{
"common_name"
:
self
.
getReference
()
"common_name"
:
self
.
getReference
()
}
}
if
self
.
getReference
()
and
self
.
get
SourceReference
():
if
self
.
getReference
()
and
self
.
get
CsrId
():
if
csr
is
not
None
:
if
csr
is
not
None
:
raise
ValueError
(
"The certificate was already requsted without the certificate sign request."
)
raise
ValueError
(
"The certificate was already requsted without the certificate sign request."
)
certificate_dict
[
"id"
]
=
self
.
get
SourceReference
()
certificate_dict
[
"id"
]
=
self
.
get
CsrId
()
crt_pem
=
caucase_connector
.
getCertificate
(
int
(
self
.
getSourceReference
()
))
crt_pem
=
caucase_connector
.
getCertificate
(
self
.
getCsrId
(
))
certificate_dict
[
"certificate"
]
=
crt_pem
certificate_dict
[
"certificate"
]
=
crt_pem
# We should assert that reference is the CN of crt_pem
# We should assert that reference is the CN of crt_pem
return
certificate_dict
return
certificate_dict
...
@@ -75,18 +75,18 @@ class CertificateLoginMixin:
...
@@ -75,18 +75,18 @@ class CertificateLoginMixin:
caucase_connector
.
createCertificate
(
csr_id
,
template_csr
=
template_csr
)
caucase_connector
.
createCertificate
(
csr_id
,
template_csr
=
template_csr
)
crt_pem
=
caucase_connector
.
getCertificate
(
csr_id
)
crt_pem
=
caucase_connector
.
getCertificate
(
csr_id
)
self
.
set
SourceReference
(
csr_id
)
self
.
set
CsrId
(
csr_id
)
return
{
return
{
"certificate"
:
crt_pem
,
"certificate"
:
crt_pem
,
"id"
:
self
.
get
SourceReference
(),
"id"
:
self
.
get
CsrId
(),
"common_name"
:
reference
"common_name"
:
reference
}
}
security
.
declarePublic
(
'getCertificate'
)
security
.
declarePublic
(
'getCertificate'
)
def
getCertificate
(
self
,
csr
=
None
):
def
getCertificate
(
self
,
csr
=
None
):
"""Returns new SSL certificate"""
"""Returns new SSL certificate"""
if
csr
is
None
and
self
.
get
SourceReference
()
is
None
:
if
csr
is
None
and
self
.
get
CsrId
()
is
None
:
key
,
csr
=
self
.
_getCaucaseConnector
().
_createCertificateRequest
()
key
,
csr
=
self
.
_getCaucaseConnector
().
_createCertificateRequest
()
certificate_dict
=
self
.
_getCertificate
(
csr
=
csr
)
certificate_dict
=
self
.
_getCertificate
(
csr
=
csr
)
certificate_dict
[
"key"
]
=
key
certificate_dict
[
"key"
]
=
key
...
@@ -96,13 +96,13 @@ class CertificateLoginMixin:
...
@@ -96,13 +96,13 @@ class CertificateLoginMixin:
def
_revokeCertificate
(
self
,
key_pem
=
None
):
def
_revokeCertificate
(
self
,
key_pem
=
None
):
if
self
.
getDestinationReference
()
is
not
None
or
(
if
self
.
getDestinationReference
()
is
not
None
or
(
self
.
getReference
()
is
not
None
and
self
.
get
SourceReference
()
is
None
self
.
getReference
()
is
not
None
and
self
.
get
CsrId
()
is
None
):
):
raise
ValueError
(
"You cannot revoke certificates from prior implementation!"
)
raise
ValueError
(
"You cannot revoke certificates from prior implementation!"
)
if
self
.
get
SourceReference
()
is
not
None
:
if
self
.
get
CsrId
()
is
not
None
:
caucase_connector
=
self
.
_getCaucaseConnector
()
caucase_connector
=
self
.
_getCaucaseConnector
()
crt_pem
=
caucase_connector
.
getCertificate
(
int
(
self
.
getSourceReference
()
))
crt_pem
=
caucase_connector
.
getCertificate
(
self
.
getCsrId
(
))
if
key_pem
is
None
:
if
key_pem
is
None
:
return
caucase_connector
.
revokeCertificate
(
crt_pem
,
key_pem
)
return
caucase_connector
.
revokeCertificate
(
crt_pem
,
key_pem
)
return
caucase_connector
.
revokeCertificate
(
crt_pem
)
return
caucase_connector
.
revokeCertificate
(
crt_pem
)
...
...
bt5/erp5_certificate_authority/PortalTypePropertySheetTemplateItem/property_sheet_list.xml
View file @
fac4a0ea
...
@@ -4,4 +4,7 @@
...
@@ -4,4 +4,7 @@
<item>
Reference
</item>
<item>
Reference
</item>
<item>
Url
</item>
<item>
Url
</item>
</portal_type>
</portal_type>
<portal_type
id=
"Certificate Login"
>
<item>
CaucaseCertificateLogin
</item>
</portal_type>
</property_sheet_list>
</property_sheet_list>
\ No newline at end of file
bt5/erp5_certificate_authority/PropertySheetTemplateItem/portal_property_sheets/CaucaseCertificateLogin.xml
0 → 100644
View file @
fac4a0ea
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Property Sheet"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_count
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_mt_index
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
_tree
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CaucaseCertificateLogin
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"Length"
module=
"BTrees.Length"
/>
</pickle>
<pickle>
<int>
0
</int>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"OOBTree"
module=
"BTrees.OOBTree"
/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
bt5/erp5_certificate_authority/PropertySheetTemplateItem/portal_property_sheets/CaucaseCertificateLogin/csr_id_property.xml
0 → 100644
View file @
fac4a0ea
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Standard Property"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
elementary_type/int
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string>
Certificate Signing Request ID
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
csr_id_property
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_certificate_authority/TestTemplateItem/portal_components/test.erp5.testCertificateAuthorityPerson.py
View file @
fac4a0ea
...
@@ -27,7 +27,6 @@
...
@@ -27,7 +27,6 @@
#
#
##############################################################################
##############################################################################
#import os
import
random
import
random
from
Products.ERP5Type.tests.ERP5TypeCaucaseTestCase
import
ERP5TypeCaucaseTestCase
from
Products.ERP5Type.tests.ERP5TypeCaucaseTestCase
import
ERP5TypeCaucaseTestCase
from
Products.ERP5Type.Core.Workflow
import
ValidationFailed
from
Products.ERP5Type.Core.Workflow
import
ValidationFailed
...
@@ -325,7 +324,7 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
...
@@ -325,7 +324,7 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
SourceReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
CsrId
(),
None
)
self
.
assertEqual
(
None
,
certificate_login
.
revokeCertificate
())
self
.
assertEqual
(
None
,
certificate_login
.
revokeCertificate
())
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
...
@@ -351,7 +350,7 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
...
@@ -351,7 +350,7 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
SourceReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
CsrId
(),
None
)
self
.
assertEqual
(
None
,
certificate_login
.
revokeCertificate
(
certificate_dict
[
'key'
]))
self
.
assertEqual
(
None
,
certificate_login
.
revokeCertificate
(
certificate_dict
[
'key'
]))
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
...
@@ -377,11 +376,11 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
...
@@ -377,11 +376,11 @@ class TestPersonCertificateLogin(ERP5TypeCaucaseTestCase):
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getReference
().
decode
(
"UTF-8"
),
cn_list
[
0
])
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertEqual
(
certificate_login
.
getDestinationReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
SourceReference
(),
None
)
self
.
assertNotEqual
(
certificate_login
.
get
CsrId
(),
None
)
# Older implementation wont set it on the Certificate login
# Older implementation wont set it on the Certificate login
certificate_login
.
setDestinationReference
(
None
)
certificate_login
.
setDestinationReference
(
None
)
certificate_login
.
set
SourceReference
(
None
)
certificate_login
.
set
CsrId
(
None
)
# Still raise since it has no valid certificate anymore
# Still raise since it has no valid certificate anymore
self
.
assertRaises
(
ValueError
,
certificate_login
.
revokeCertificate
)
self
.
assertRaises
(
ValueError
,
certificate_login
.
revokeCertificate
)
...
...
bt5/erp5_certificate_authority/bt/template_portal_type_property_sheet_list
View file @
fac4a0ea
Caucase Connector | CaucaseConnector
Caucase Connector | CaucaseConnector
Caucase Connector | Reference
Caucase Connector | Reference
Caucase Connector | Url
Caucase Connector | Url
\ No newline at end of file
Certificate Login | CaucaseCertificateLogin
\ No newline at end of file
bt5/erp5_certificate_authority/bt/template_property_sheet_id_list
View file @
fac4a0ea
CaucaseCertificateLogin
CaucaseConnector
CaucaseConnector
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment