I did manage to write a Jython script that calls a soap web service and does the authentication using suds-jurko module. The standalone jython script works fine.
I am not sure whether how Gluu server would install the suds module. But I still added this part to the basic authentication script on Gluu server like below and checked the 'Enabled' check box as Gluu admin.
------------------------------------------------------------------
from org.jboss.seam.security import Identity
from org.xdi.model.custom.script.type.auth import PersonAuthenticationType
from org.xdi.oxauth.service import UserService
from org.xdi.util import StringHelper
from suds.client import Client
import java
class PersonAuthentication(PersonAuthenticationType):
def __init__(self, currentTimeMillis):
self.currentTimeMillis = currentTimeMillis
def init(self, configurationAttributes):
print "Basic. Initialization"
print "Basic. Initialized successfully"
return True
def destroy(self, configurationAttributes):
print "Basic. Destroy"
print "Basic. Destroyed successfully"
return True
def getApiVersion(self):
return 1
def isValidAuthenticationMethod(self, usageType, configurationAttributes):
return True
def getAlternativeAuthenticationMethod(self, usageType, configurationAttributes):
return None
def pdmAuthenticate(user, password):
WDSL = 'http://host/path/service?wsdl'
client = Client(WDSL)
return client.service.getAuthentication(arg0=user, arg1=password)
def authenticate(self, configurationAttributes, requestParameters, step):
if (step == 1):
print "Basic. Authenticate for step 1"
credentials = Identity.instance().getCredentials()
user_name = credentials.getUsername()
user_password = credentials.getPassword()
logged_in = False
if (StringHelper.isNotEmptyString(user_name) and StringHelper.isNotEmptyString(user_password)):
logged_in = pdmAuthenticate(user_name, user_password)
if (not logged_in):
return False
return True
else:
return False
def prepareForStep(self, configurationAttributes, requestParameters, step):
if (step == 1):
print "Basic. Prepare for Step 1"
return True
else:
return False
def getExtraParametersForStep(self, configurationAttributes, step):
return None
def getCountAuthenticationSteps(self, configurationAttributes):
return 1
def getPageForStep(self, configurationAttributes, step):
return ""
def logout(self, configurationAttributes, requestParameters):
return True
------------------------------------------------------------------
After this further calls to Gluu server fails with the following error
Error Encountered
An unexpected error has occurred at 2017-03-07 02:17:42 PM.
Failed to authenticate
The oxauth.log has the following error
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96) [jboss-el-1.0_02.CR6.jar:1.0_02.CR6]
2017-03-07 14:17:31,731 ERROR [qtp1395089624-18] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:345) - Failed to determine alternative authentication mode for acr_values: 'basic'
2017-03-07 14:17:42,345 ERROR [qtp1395089624-14] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:252) - null
java.lang.NullPointerException: null
at org.xdi.oxauth.service.external.ExternalAuthenticationService.executeExternalGetPageForStep(ExternalAuthenticationService.java:250)
2017-03-07 14:17:42,406 ERROR [qtp1395089624-15] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:137) - null
java.lang.NullPointerException: null
at org.xdi.oxauth.service.external.ExternalAuthenticationService.executeExternalIsValidAuthenticationMethod(ExternalAuthenticationService.java:135) [classes/:?]
at org.xdi.oxauth.service.external.ExternalAuthenticationService.determineExternalAuthenticatorForWorkflow(ExternalAuthenticationService.java:339) [classes/:?]
2017-03-07 14:17:42,408 WARN [qtp1395089624-15] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:341) - Current acr_values: 'basic' isn't valid
2017-03-07 14:17:42,408 ERROR [qtp1395089624-15] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:150) - null
java.lang.NullPointerException: null
at org.xdi.oxauth.service.external.ExternalAuthenticationService.executeExternalGetAlternativeAuthenticationMethod(ExternalAuthenticationService.java:148) [classes/:?]
at org.xdi.oxauth.service.external.ExternalAuthenticationService.determineExternalAuthenticatorForWorkflow(ExternalAuthenticationService.java:343) [classes/:?]
2017-03-07 14:17:42,421 ERROR [qtp1395089624-15] [org.xdi.oxauth.service.external.ExternalAuthenticationService] (ExternalAuthenticationService.java:345) - Failed to determine alternative authentication mode for acr_values: 'basic'
Any idea what went wrong here?