You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:18:15 UTC

[sling-org-apache-sling-auth-xing-oauth] 02/08: SLING-3731 null out OAuthService on incomplete configuration parameters and add OAuthService null checks

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.auth.xing.oauth-0.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-xing-oauth.git

commit fb054286f782ba7d17fb7d09059ae60171d06ff2
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Jul 6 13:53:01 2014 +0000

    SLING-3731 null out OAuthService on incomplete configuration parameters and add OAuthService null checks
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/auth/org.apache.sling.auth.xing.oauth@1608200 13f79535-47bb-0310-9956-ffa450edef68
---
 .../xing/oauth/impl/XingOauthAuthenticationHandler.java     | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java b/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java
index 79f58d0..1ee4e47 100644
--- a/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java
+++ b/src/main/java/org/apache/sling/auth/xing/oauth/impl/XingOauthAuthenticationHandler.java
@@ -147,6 +147,8 @@ public class XingOauthAuthenticationHandler extends DefaultAuthenticationFeedbac
 
         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 XingOauthAuthenticationHandler extends DefaultAuthenticationFeedbac
     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 XingOauthAuthenticationHandler extends DefaultAuthenticationFeedbac
     @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);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.