Author: olli Date: Sun Jul 6 13:53:01 2014 New Revision: 1608200 URL: http://svn.apache.org/r1608200 Log: SLING-3731 null out OAuthService on incomplete configuration parameters and add OAuthService null checks
Modified: sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java Modified: sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java?rev=1608200&r1=1608199&r2=1608200&view=diff ============================================================================== --- sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java (original) +++ sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java Sun Jul 6 13:53:01 2014 @@ -147,6 +147,8 @@ public class XingOauthAuthenticationHand if (!StringUtils.isEmpty(consumerKey) && !StringUtils.isEmpty(consumerSecret) && !StringUtils.isEmpty(callbackUrl)) { oAuthService = new ServiceBuilder().provider(XingApi.class).apiKey(consumerKey).apiSecret(consumerSecret).callback(callbackUrl).build(); + } else { + oAuthService = null; } logger.info("configured with consumer key '{}', callback url '{}' and users me url '{}'", consumerKey, callbackUrl, usersMeUrl); @@ -157,6 +159,11 @@ public class XingOauthAuthenticationHand public AuthenticationInfo extractCredentials(final HttpServletRequest request, final HttpServletResponse response) { logger.debug("extract credentials"); + if (oAuthService == null) { + logger.error("OAuthService is null, check configuration"); + return null; + } + try { final HttpSession httpSession = request.getSession(true); @@ -195,6 +202,12 @@ public class XingOauthAuthenticationHand @Override public boolean requestCredentials(final HttpServletRequest request, final HttpServletResponse response) throws IOException { logger.debug("request credentials"); + + if (oAuthService == null) { + logger.error("OAuthService is null, check configuration"); + return false; + } + try { final Token requestToken = oAuthService.getRequestToken(); logger.debug("received request token: '{}'", requestToken);