Commit c607a4cf authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_web: form to generate certificate using caucase

parent 792059be
...@@ -2,17 +2,18 @@ person = context.ERP5Site_getAuthenticatedMemberPersonValue() ...@@ -2,17 +2,18 @@ person = context.ERP5Site_getAuthenticatedMemberPersonValue()
request = context.REQUEST request = context.REQUEST
response = request.RESPONSE response = request.RESPONSE
certificate = url = ""
if person is None: if person is None:
response.setStatus(403) response.setStatus(403)
else: else:
try: try:
_, url = person.signCertificate(certificate_signature_request)
request.set('portal_status_message', context.Base_translateString('New Certificate created.'))
certificate = person.getCertificate() certificate = person.getCertificate()
request.set('portal_status_message', context.Base_translateString('Certificate created.'))
except ValueError: except ValueError:
certificate = {'certificate': '', 'key': ''}
request.set('portal_status_message', context.Base_translateString('Certificate was already requested, please revoke existing one.')) request.set('portal_status_message', context.Base_translateString('Certificate was already requested, please revoke existing one.'))
response.setStatus(403) response.setStatus(403)
request.set('your_certificate', certificate['certificate']) request.set('your_certificate', certificate)
request.set('your_key', certificate['key']) request.set('your_certificate_url', url)
return context.WebSection_viewCertificateAsWeb() return context.WebSection_viewCertificateAsWeb()
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value> <value> <string>certificate_signature_request, **kwargs</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
computer = context computer = context
request = context.REQUEST request = context.REQUEST
try: try:
computer.generateCertificate() computer.generateCertificate(csr=certificate_signature_request)
request.set('portal_status_message', context.Base_translateString('Certificate created.')) request.set('portal_status_message', context.Base_translateString('Certificate created.'))
except ValueError: except ValueError:
request.set('portal_status_message', context.Base_translateString('Certificate is still active, please revoke existing one.')) request.set('portal_status_message', context.Base_translateString('Certificate is still active, please revoke existing one.'))
request.set('your_certificate', request.get('computer_certificate')) request.set('your_certificate', request.get('computer_certificate'))
request.set('your_key', request.get('computer_key')) request.set('your_certificate_url', request.get('certificate_url'))
return context.Computer_viewConnectionInformationAsWeb() return context.Computer_viewConnectionInformationAsWeb()
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_id, *args, **kwargs</string> </value> <value> <string>form_id, certificate_signature_request, *args, **kwargs</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -2,7 +2,7 @@ person = context.ERP5Site_getAuthenticatedMemberPersonValue() ...@@ -2,7 +2,7 @@ person = context.ERP5Site_getAuthenticatedMemberPersonValue()
try: try:
person.revokeCertificate() person.revokeCertificate()
message = context.Base_translateString('Certificate revoked.') message = context.Base_translateString('Certificate revoked.')
except ValueError: except ValueError, e:
message = context.Base_translateString('No certificate found.') message = context.Base_translateString('No certificate found. %s' % str(e))
return context.getWebSiteValue().myspace.my_account.Base_redirect(keep_items=dict(portal_status_message=message)) return context.getWebSiteValue().myspace.my_account.Base_redirect(keep_items=dict(portal_status_message=message))
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
<value> <value>
<list> <list>
<string>your_information</string> <string>your_information</string>
<string>your_key</string> <string>your_certificate_url</string>
<string>your_certificate</string> <string>your_certificate</string>
</list> </list>
</value> </value>
......
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string>Please copy and store in safe place certificate and key.\n <value> <string>Please copy/download certificate and store in safe place.\n
\n \n
You can use them with slap library, for example in slap console.</string> </value> You can use them with slap library, for example in slap console.</string> </value>
</item> </item>
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
<value> <value>
<list> <list>
<string>your_description</string> <string>your_description</string>
<string>my_certificate_signature_request</string>
<string>your_common_name</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>your_key</string> </value> <value> <string>my_certificate_signature_request</string> </value>
</item> </item>
<item> <item>
<key> <string>message_values</string> </key> <key> <string>message_values</string> </key>
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
</item> </item>
<item> <item>
<key> <string>css_class</string> </key> <key> <string>css_class</string> </key>
<value> <string>inline</string> </value> <value> <string></string> </value>
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
<value> <string></string> </value> <value> <string>Put here the CSR string in PEM format</string> </value>
</item> </item>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
...@@ -233,7 +233,7 @@ ...@@ -233,7 +233,7 @@
</item> </item>
<item> <item>
<key> <string>height</string> </key> <key> <string>height</string> </key>
<value> <int>10</int> </value> <value> <int>15</int> </value>
</item> </item>
<item> <item>
<key> <string>hidden</string> </key> <key> <string>hidden</string> </key>
...@@ -257,7 +257,7 @@ ...@@ -257,7 +257,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Key</string> </value> <value> <string>Certificate Signature Request (CSR)</string> </value>
</item> </item>
<item> <item>
<key> <string>unicode</string> </key> <key> <string>unicode</string> </key>
......
...@@ -209,13 +209,11 @@ ...@@ -209,13 +209,11 @@
</item> </item>
<item> <item>
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string>Here you can request new SSL certificate.\n <value> <string>Here you can request a signed SSL certificate.\n
\n
After presenting it please copy key and certificate and store in secure place.\n
\n \n
In case of certificate compromise or lost please request it again.\n In case of certificate compromise or lost please request it again.\n
\n \n
Certificate is not stored on Vifib.net servers</string> </value> Certificate is not stored on Vifib.net servers.</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
<value> <value>
<list> <list>
<string>your_description</string> <string>your_description</string>
<string>my_certificate_signature_request</string>
<string>your_common_name</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
<key> <string>default</string> </key> <key> <string>default</string> </key>
<value> <string>Here you can request a new SSL certificate for computer.\n <value> <string>Here you can request a new SSL certificate for computer.\n
\n \n
After presenting it please copy key and certificate and store in secure place.\n After presenting it please copy the certificate and store in secure place.\n
\n \n
In case of certificate compromise or lost please request it again.\n In case of certificate compromise or lost please request it again.\n
\n \n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment