Dear,
I installed the Social Login extension from the control panel in the
last xwiki-xem manager with two sub-wiki, I can't get the login working.
I attached the full error, it's a null pointer exceptions, but I can't
find a reference to the exact macro line.
Thank you,
Gianluca
org.xwiki.rendering.macro.MacroExecutionException: Failed to evaluate
Script Macro for content [import org.brickred.socialauth.AuthProvider
import org.brickred.socialauth.AuthProviderFactory
/**
* Displays a form with a single field for a new SSO user to pickup
its usernamem
*/
def outputUsernameCreationForm = { defaultValue, provider ->
if (!defaultValue)
defaultValue = ""
xwiki.ssx.use('XWiki.SocialLogin')
println """
{{html clean=false}}
<form class="xform" action=${doc.getURL('view')}
method="post"
id="createUsernameForm">
<div class="centered">
<fieldset class="xwikimessage">
<legend><span>${msg.get('xwiki.socialLogin.youMustBeNewHere')}</
span></legend>
<input type="hidden" name="xaction"
value="createProfile" />
<p class="message">
${msg.get('xwiki.socialLogin.createProfileMessage',
[provider])}
</p>
<dl>
<dt>${msg.get('xwiki.socialLogin.pickupUsername')}</dt>
<dd><input type="text" name="username" value="$
{defaultValue}" /></dd>
</dl>
<div class="buttons">
<span class="buttonwrapper">
<input class="button" type="submit" value="$
{msg.get('xwiki.socialLogin.createMyAccount')}" />
</span>
</div>
</fieldset>
</div>
</form>
{{/html}}
"""
}
/**
* Authenticate a user and make it remembered in XWiki authentication
system
*/
def authenticateUser = { userDoc ->
def password =
userDoc
.getObject('XWiki.SocialLoginClass').getProperty('password_cache').value
def xwikiAuthenticator =
xwiki.@xwiki.getAuthService().@authenticators.get('xwiki')
def psm = xwikiAuthenticator.@persistentLoginManager
psm.rememberLogin(request, response, userDoc.fullName, password)
response.sendRedirect(xwiki.getURL('Main.WebHome', 'view'))
}
// Load oauth properties file
def properties = new java.util.Properties()
properties
.load
(com
.xpn
.xwiki
.web
.Utils
.getComponent
("org
.xwiki.container.Container").applicationContext.getResourceAsStream("/
WEB-INF/oauth_consumer.properties"))
/**
* Initiate the OAuth dance with the requested provider
*/
if(!request.callback && request.provider) {
try {
def provider = AuthProviderFactory.getInstance(request.provider,
properties)
println provider
String url =
provider.getLoginRedirectURL(doc.getExternalURL('view','callback=1'));
// Store in session
request.session.setAttribute("org.brickred.socialauth.AuthProvider",
provider);
request
.session.setAttribute("org.brickred.socialauth.AuthProvider.hint",
request.provider);
response.sendRedirect(url)
}
catch(Exception e) {
println """
{{error}}
${msg.get('xwiki.socialLogin.genericError', [e.message])}
{{/error}}
"""
}
}
/**
* We've got a response from the provider, let's treat it
*/
else if (request.callback){
try {
// get the provider back from session
def provider =
request.session.getAttribute("org.brickred.socialauth.AuthProvider");
def providerID =
request
.session.getAttribute("org.brickred.socialauth.AuthProvider.hint");
// verify the authentication
def profile = provider.verifyResponse(request);
// Search for this user in database
def query = services.query.xwql("from
doc.object(XWiki.XWikiUsers) as user,
doc.object(XWiki.SocialLoginProfileClass) as profile where
profile.provider = '" + providerID + "' and profile.validatedId =
'" +
profile.validatedId + "'")
for (result in query.execute()) {
authenticateUser(xwiki.getDocument(result))
}
// Not authenticated/redirected yet ? -> You must be new here
// You will have to pick-up a username and dad will create an
account for you
// Store the social profile in the session
request.session.setAttribute("org.brickred.socialauth.Profile",
profile);
// Try to guess what username the user will want to use
def guessedUsername = profile.displayName
// Outputs the form to create the username
outputUsernameCreationForm(guessedUsername, providerID)
} catch(Exception e) {
println """
{{error}}
${msg.get('xwiki.socialLogin.genericError', [e.message])}
{{/error}}
"""
}
}
/**
* Create a new user profile from the social profile result
*/
else if (request.xaction && request.xaction == 'createProfile') {
def profile =
request.session.getAttribute("org.brickred.socialauth.Profile")
def provider =
request
.session.getAttribute("org.brickred.socialauth.AuthProvider.hint");
def username = request.username
if (username && username != '' &&
!xwiki.exists("XWiki." +
username)) {
// Everything clear, let's proceed
def userDocName = "XWiki." + username
// Generate a random password
password = xwiki.generateRandomString(16)
def propMap = [:]
propMap.put("active", "1")
propMap.put("email", profile.email)
propMap.put("first_name", profile.firstName)
propMap.put("last_name", profile.lastName)
propMap.put("password", password)
xwiki.(a)xwiki.createUser(username, propMap, xcontext.@context)
def userDoc = xwiki.getDocument(userDocName)
def socialProfile =
userDoc.getObject('XWiki.SocialLoginProfileClass', true)
socialProfile.set('provider', provider)
socialProfile.set('fullName', profile.fullName)
socialProfile.set('firstName', profile.firstName)
socialProfile.set('lastName', profile.lastName)
socialProfile.set('displayName', profile.displayName)
socialProfile.set('email', profile.email)
socialProfile.set('profileImageURL', profile.profileImageURL)
socialProfile.set('gender', profile.gender)
socialProfile.set('dob', profile.dob)
socialProfile.set('validatedId', profile.validatedId)
socialProfile.set('country', profile.country)
socialProfile.set('location', profile.location)
def socialPrefs = userDoc.getObject('XWiki.SocialLoginClass', true)
socialPrefs.set('password_cache', password)
socialPrefs.set('preferred_provider', provider)
userDoc
.saveWithProgrammingRights
(msg.get('xwiki.socialLogin.updatedSocialProfile'), true)
authenticateUser(userDoc)
}
else {
if (!username || username == '')
println """
{{error}}
${msg.get('xwiki.socialLogin.youMustPickUsername')}
{{/error}}
"""
else if (xwiki.exists('XWiki.' + username))
println """
{{error}}
${msg.get('xwiki.socialLogin.usernameAlreadyTaken')}
{{/error}}
"""
outputUsernameCreationForm("", provider);
}
}
/**
* View mode
*/
else {
println """
{{info}}
${msg.get('xwiki.socialLogin.nothingToDo')}
{{/info}}
"""
}]
at
org
.xwiki
.rendering
.macro
.script
.AbstractJSR223ScriptMacro
.evaluateBlock(AbstractJSR223ScriptMacro.java:174)
at
org
.xwiki
.rendering
.macro
.script
.AbstractJSR223ScriptMacro
.evaluateBlock(AbstractJSR223ScriptMacro.java:52)
at
org
.xwiki
.rendering
.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:198)
at
org
.xwiki
.rendering
.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:59)
at
org
.xwiki
.rendering
.internal
.transformation
.macro.MacroTransformation.transformOnce(MacroTransformation.java:187)
at
org
.xwiki
.rendering
.internal
.transformation
.macro.MacroTransformation.transform(MacroTransformation.java:132)
at
org
.xwiki
.rendering
.internal
.transformation
.DefaultTransformationManager
.performTransformations(DefaultTransformationManager.java:83)
at
org
.xwiki
.display
.internal
.DocumentContentDisplayer.display(DocumentContentDisplayer.java:248)
at
org
.xwiki
.display
.internal
.DocumentContentDisplayer.display(DocumentContentDisplayer.java:124)
at
org
.xwiki
.display
.internal
.DocumentContentDisplayer.display(DocumentContentDisplayer.java:54)
at
org
.xwiki
.display
.internal
.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:80)
at
org
.xwiki
.display
.internal
.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:38)
at
com
.xpn
.xwiki
.internal
.sheet.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:113)
at
com
.xpn
.xwiki
.internal
.sheet.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:57)
at
org
.xwiki
.display
.internal
.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:
67)
at
org
.xwiki
.display
.internal
.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:
41)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:
862)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:
841)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:
872)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:586)
at sun.reflect.GeneratedMethodAccessor3514.invoke(Unknown Source)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.velocity.util.introspection.UberspectImpl
$VelMethodImpl.doInvoke(UberspectImpl.java:395)
at org.apache.velocity.util.introspection.UberspectImpl
$VelMethodImpl.invoke(UberspectImpl.java:384)
at
org
.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:
173)
at
org
.apache
.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:
280)
at
org
.apache
.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:567)
at
org
.apache
.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
at
org
.apache
.velocity
.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:
72)
at
org
.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:
342)
at
org
.apache
.velocity
.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
at
org
.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:
342)
at
org
.xwiki
.velocity
.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228)
at
org
.xwiki
.velocity
.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:184)
at
com
.xpn
.xwiki
.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:117)
at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1791)
at com.xpn.xwiki.XWiki.parseTemplate(XWiki.java:1728)
at com.xpn.xwiki.api.XWiki.parseTemplate(XWiki.java:839)
at sun.reflect.GeneratedMethodAccessor3337.invoke(Unknown Source)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.velocity.util.introspection.UberspectImpl
$VelMethodImpl.doInvoke(UberspectImpl.java:395)
at org.apache.velocity.util.introspection.UberspectImpl
$VelMethodImpl.invoke(UberspectImpl.java:384)
at
org
.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:
173)
at
org
.apache
.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:
280)
at
org
.apache
.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:
72)
at
org
.apache
.velocity
.runtime.directive.VelocimacroProxy.render(VelocimacroProxy.java:216)
at
org
.apache
.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:311)
at
org
.apache
.velocity.runtime.directive.RuntimeMacro.render(RuntimeMacro.java:230)
at
org
.apache
.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:207)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:
72)
at
org
.apache
.velocity
.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
at
org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:
72)
at
org
.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:
342)
at
org
.apache
.velocity
.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:106)
at
org
.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:
342)
at
org
.xwiki
.velocity
.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228)
at
org
.xwiki
.velocity
.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:184)
at
com
.xpn
.xwiki
.render.XWikiVelocityRenderer.evaluate(XWikiVelocityRenderer.java:117)
at com.xpn.xwiki.XWiki.evaluateTemplate(XWiki.java:1791)
at com.xpn.xwiki.web.Utils.parseTemplate(Utils.java:154)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:241)
at com.xpn.xwiki.web.XWikiAction.execute(XWikiAction.java:116)
at
org
.apache
.struts
.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at
org
.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:
1196)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:
538)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1352)
at com.xpn.xwiki.web.ActionFilter.doFilter(ActionFilter.java:128)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1323)
at
org
.xwiki
.wysiwyg.server.filter.ConversionFilter.doFilter(ConversionFilter.java:
144)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1323)
at
com
.xpn.xwiki.plugin.webdav.XWikiDavFilter.doFilter(XWikiDavFilter.java:68)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1323)
at
org
.xwiki
.container
.servlet
.filters
.internal
.SavedRequestRestorerFilter.doFilter(SavedRequestRestorerFilter.java:
217)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1323)
at
org
.xwiki
.container
.servlet
.filters
.internal
.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:
109)
at org.eclipse.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1323)
at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:
476)
at
org
.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:
119)
at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:
517)
at
org
.eclipse
.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
at
org
.eclipse
.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)
at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
406)
at
org
.eclipse
.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
at
org
.eclipse
.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)
at
org
.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:
117)
at
org
.eclipse
.jetty
.server
.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:
247)
at
org
.eclipse
.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:
149)
at
org
.eclipse
.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:346)
at
org
.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:
589)
at org.eclipse.jetty.server.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:1048)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:601)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:
214)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:
411)
at
org
.eclipse
.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:
535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint
$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool
$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Thread.java:679)
Caused by: javax.script.ScriptException: javax.script.ScriptException:
java.lang.NullPointerException
at
org
.codehaus
.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:
122)
at
org
.xwiki
.rendering
.macro
.script.AbstractJSR223ScriptMacro.eval(AbstractJSR223ScriptMacro.java:
277)
at
org
.xwiki
.rendering
.macro
.script
.AbstractJSR223ScriptMacro
.evaluateBlock(AbstractJSR223ScriptMacro.java:209)
at
org
.xwiki
.rendering
.macro
.script
.AbstractJSR223ScriptMacro
.evaluateBlock(AbstractJSR223ScriptMacro.java:169)
... 105 more
Caused by: javax.script.ScriptException: java.lang.NullPointerException
at
org
.codehaus
.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:
323)
at
org
.codehaus
.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:
116)
... 108 more
Caused by: java.lang.NullPointerException