Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

small additions to the create user/cert functionality.

  • Loading branch information...
commit 855e46b60b032b50cc949d53e3ed1888589b261a 1 parent ae3cdd1
@clemesha-ooi clemesha-ooi authored
View
1  .gitignore
@@ -2,6 +2,7 @@
*.iml
*.ipr
*.iws
+*.swp
build/
dist/
autocontainer/downloads/
View
13 web/src/python/nimbusweb/portal/usercreate/util.py
@@ -6,14 +6,13 @@ def create_nimbus_user_stub(dn):
return nimbus_userid
create_nimbus_user = create_nimbus_user_stub
-def extract_dn_stub(cert, key):
- new_users_dn = "test_dn"
- return new_users_dn
-extract_dn = extract_dn_stub
+def extract_dn(cert):
+ ezpz = EzPzCA(settings.NIMBUS_CADIR, settings.WEBDIR)
+ (DN, cert, key) = ezpz.get_cert_dn(cert)
+ return (DN, cert, key)
+
-def autocreate_cert_stub(cn):
- new_users_dn = "test_dn"
- return new_users_dn
+autocreate_cert_stub = lambda x: ("test_dn", "test_cert", "test_key")
autocreate_cert = autocreate_cert_stub
def autocreate_cert(cn):
View
12 web/src/python/nimbusweb/portal/usercreate/views.py
@@ -30,11 +30,11 @@ def method(request, method):
cert = form.cleaned_data["cert"]
key = form.cleaned_data["key"]
print cert, key, type(cert), type(key)
+ #TODO get string contents out of cert
try:
- dn = util.extract_dn(cert, key)
+ dn = util.extract_dn(cert)
except:
- #TODO: better error:
- raise Exception("Failed getting DN from cert and key")
+ raise Exception("Failed getting DN from cert.") #TODO: better error.
else:
form = CertKeyForm()
@@ -54,7 +54,10 @@ def method(request, method):
form = AutoCreateForm(request.POST)
if form.is_valid():
cn = form.cleaned_data["username"] #username is used as the CN (common name)
- (dn, cert, key) = util.autocreate_cert(cn)
+ try:
+ (dn, cert, key) = util.autocreate_cert(cn)
+ except:
+ raise Exception("Failed autocreating new cert and key.") #TODO: better error.
else:
form = AutoCreateForm()
@@ -67,6 +70,7 @@ def method(request, method):
nimbus_userid = util.create_nimbus_user(dn) #if this fails, new User is deleted.
#TODO save 'nimbus_userid' to UserProfile here, or does util.create_nimbus_user do it?
print "=== final data ==> ", username, firstname, lastname, email, nimbus_userid
+ #TODO: use 'nimbus.adminops._newuser(newuserform, request_files)' here:
unique_new_user_token="abc123"
return HttpResponseRedirect("/usercreate/success?token="+unique_new_user_token)
except:
Please sign in to comment.
Something went wrong with that request. Please try again.