From b612415a882055dc4530122181aa76e68bacd83a Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 14 Nov 2016 13:34:35 -0200 Subject: [PATCH] [KEYCLOAK-3900] - SSSD Provider: NullPointerException when SSSD is stopped --- .../federation/sssd/api/SSSDException.java | 17 +++++++++++++++++ .../org/keycloak/federation/sssd/api/Sssd.java | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 federation/sssd/src/main/java/org/keycloak/federation/sssd/api/SSSDException.java diff --git a/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/SSSDException.java b/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/SSSDException.java new file mode 100644 index 0000000000..c03c9263a4 --- /dev/null +++ b/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/SSSDException.java @@ -0,0 +1,17 @@ +package org.keycloak.federation.sssd.api; + +/** + * @author Bruno Oliveira + */ +public class SSSDException extends RuntimeException { + public SSSDException() { + } + + public SSSDException(String message) { + super(message); + } + + public SSSDException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/Sssd.java b/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/Sssd.java index 5d62ce4ba7..9cfee78daa 100644 --- a/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/Sssd.java +++ b/federation/sssd/src/main/java/org/keycloak/federation/sssd/api/Sssd.java @@ -94,19 +94,19 @@ public class Sssd { InfoPipe infoPipe = infopipe(); attributes = infoPipe.getUserAttributes(username, Arrays.asList(attr)); } catch (Exception e) { - logger.error("Failed to retrieve user's attributes from SSSD", e); + throw new SSSDException("Failed to retrieve user's attributes. Check if SSSD service is active."); } return attributes; } public List getUserGroups() { - List userGroups = null; + List userGroups; try { InfoPipe infoPipe = Sssd.infopipe(); userGroups = infoPipe.getUserGroups(username); } catch (Exception e) { - logger.error("Failed to retrieve user's groups from SSSD", e); + throw new SSSDException("Failed to retrieve user's groups from SSSD. Check if SSSD service is active."); } return userGroups; }