sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romb...@apache.org
Subject [sling-org-apache-sling-auth-xing-oauth] 02/08: SLING-3731 null out OAuthService on incomplete configuration parameters and add OAuthService null checks
Date Tue, 07 Nov 2017 09:18:15 GMT
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 <olli@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" <commits@sling.apache.org>.

Mime
View raw message