import M2Crypto
-import snfOCCI.config
+from snfOCCI.config import VOMS_CONFIG
import voms_helper
import exception
cert = ssl_info.get(SSL_CLIENT_CERT_ENV, "")
chain = ssl_info.get(SSL_CLIENT_CERT_CHAIN_0_ENV, "")
+
cert = M2Crypto.X509.load_cert_string(cert)
aux = M2Crypto.X509.load_cert_string(chain)
chain = M2Crypto.X509.X509_Stack()
chain.push(aux)
- return cert, chain
+
+ return (cert, chain)
-def _get_voms_info(self, ssl_info):
+def _get_voms_info(ssl_info):
"""Extract voms info from ssl_info and return dict with it."""
try:
- cert, chain = self._get_cert_chain(ssl_info)
- except M2Crypto.X509.X509Error:
- print "Error getting certificate chain"
+ cert, chain = _get_cert_chain(ssl_info)
+ except M2Crypto.X509.X509Error as e:
+ print e
with voms_helper.VOMS(VOMS_CONFIG["vomsdir_path"],VOMS_CONFIG["ca_path"], VOMS_CONFIG["vomsapi_lib"]) as v:
- if self._no_verify:
- v.set_no_verify()
+
voms_data = v.retrieve(cert, chain)
+
+
if not voms_data:
+ print "error \n"
raise VomsError(v.error.value)
d = {}
return (vogroup, role, capability)
-def authenticate(self, ssl_data):
+def authenticate(ssl_data):
try:
- voms_info = self._get_voms_info(ssl_data)
+ voms_info = _get_voms_info(ssl_data)
except VomsError as e:
raise e