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()
request = context.REQUEST
response = request.RESPONSE
certificate = url = ""
if person is None:
response.setStatus(403)
else:
try:
_, url = person.signCertificate(certificate_signature_request)
request.set('portal_status_message', context.Base_translateString('New Certificate created.'))
certificate = person.getCertificate()
request.set('portal_status_message', context.Base_translateString('Certificate created.'))
except ValueError:
certificate = {'certificate': '', 'key': ''}
request.set('portal_status_message', context.Base_translateString('Certificate was already requested, please revoke existing one.'))
response.setStatus(403)
request.set('your_certificate', certificate['certificate'])
request.set('your_key', certificate['key'])
request.set('your_certificate', certificate)
request.set('your_certificate_url', url)
return context.WebSection_viewCertificateAsWeb()
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
<value> <string>certificate_signature_request, **kwargs</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
computer = context
request = context.REQUEST
try:
computer.generateCertificate()
computer.generateCertificate(csr=certificate_signature_request)
request.set('portal_status_message', context.Base_translateString('Certificate created.'))
except ValueError:
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_key', request.get('computer_key'))
request.set('your_certificate_url', request.get('certificate_url'))
return context.Computer_viewConnectionInformationAsWeb()
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
......@@ -2,7 +2,7 @@ person = context.ERP5Site_getAuthenticatedMemberPersonValue()
try:
person.revokeCertificate()
message = context.Base_translateString('Certificate revoked.')
except ValueError:
message = context.Base_translateString('No certificate found.')
except ValueError, e:
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))
......@@ -87,7 +87,7 @@
<value>
<list>
<string>your_information</string>
<string>your_key</string>
<string>your_certificate_url</string>
<string>your_certificate</string>
</list>
</value>
......
......@@ -209,7 +209,7 @@
</item>
<item>
<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
You can use them with slap library, for example in slap console.</string> </value>
</item>
......
......@@ -87,6 +87,8 @@
<value>
<list>
<string>your_description</string>
<string>my_certificate_signature_request</string>
<string>your_common_name</string>
</list>
</value>
</item>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>your_key</string> </value>
<value> <string>my_certificate_signature_request</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -205,7 +205,7 @@
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string>inline</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
......@@ -213,7 +213,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
<value> <string>Put here the CSR string in PEM format</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>height</string> </key>
<value> <int>10</int> </value>
<value> <int>15</int> </value>
</item>
<item>
<key> <string>hidden</string> </key>
......@@ -257,7 +257,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Key</string> </value>
<value> <string>Certificate Signature Request (CSR)</string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
......
......@@ -209,13 +209,11 @@
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Here you can request new SSL certificate.\n
\n
After presenting it please copy key and certificate and store in secure place.\n
<value> <string>Here you can request a signed SSL certificate.\n
\n
In case of certificate compromise or lost please request it again.\n
\n
Certificate is not stored on Vifib.net servers</string> </value>
Certificate is not stored on Vifib.net servers.</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -87,6 +87,8 @@
<value>
<list>
<string>your_description</string>
<string>my_certificate_signature_request</string>
<string>your_common_name</string>
</list>
</value>
</item>
......
......@@ -211,7 +211,7 @@
<key> <string>default</string> </key>
<value> <string>Here you can request a new SSL certificate for computer.\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
In case of certificate compromise or lost please request it again.\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