karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5496) NPEs in SyncopeLoginModule if "version" is not specified
Date Thu, 23 Nov 2017 13:25:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264316#comment-16264316
] 

ASF GitHub Bot commented on KARAF-5496:
---------------------------------------

jbonofre closed pull request #398: KARAF-5496 - NPEs in SyncopeLoginModule if "version" is
not specified
URL: https://github.com/apache/karaf/pull/398
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java
b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java
index 1e194b633f..0e4ae97333 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java
@@ -84,7 +84,9 @@ public boolean login() throws LoginException {
         Credentials creds = new UsernamePasswordCredentials(user, password);
         client.getCredentialsProvider().setCredentials(AuthScope.ANY, creds);
         HttpGet get = new HttpGet(address + "/users/self");
-        if (version.equals("2.x") || version.equals("2")) {
+
+        boolean version2 = version != null && (version.equals("2.x") || version.equals("2"));
+        if (version2) {
             get.setHeader("Content-Type", "application/json");
         } else {
             get.setHeader("Content-Type", "application/xml");
@@ -102,7 +104,7 @@ public boolean login() throws LoginException {
             principals.add(new UserPrincipal(user));
             LOGGER.debug("Retrieving user {} roles", user);
             String responseSt = EntityUtils.toString(response.getEntity());
-            if (version.equals("2.x") || version.equals("2")) {
+            if (version2) {
                 roles = extractingRolesSyncope2(responseSt);
             } else {
                 roles = extractingRolesSyncope1(responseSt);
@@ -136,7 +138,7 @@ public boolean login() throws LoginException {
                 response = response.substring(index + "<memberships>".length());
                 index = response.indexOf("</memberships>");
                 response = response.substring(0, index);
-    
+
                 // looking for the roleName elements
                 index = response.indexOf("<roleName>");
                 while (index != -1) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> NPEs in SyncopeLoginModule if "version" is not specified
> --------------------------------------------------------
>
>                 Key: KARAF-5496
>                 URL: https://issues.apache.org/jira/browse/KARAF-5496
>             Project: Karaf
>          Issue Type: Bug
>    Affects Versions: 4.1.3
>            Reporter: Colm O hEigeartaigh
>            Assignee: Jean-Baptiste Onofré
>             Fix For: 4.1.4, 4.2.0
>
>
> There are some NPEs in the SyncopeLoginModule if "version" is not specified.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message