[KEYCLOAK-3900] - SSSD Provider: NullPointerException when SSSD is stopped

This commit is contained in:
Bruno Oliveira 2016-11-14 13:34:35 -02:00
parent 6c64494620
commit b612415a88
2 changed files with 20 additions and 3 deletions

View file

@ -0,0 +1,17 @@
package org.keycloak.federation.sssd.api;
/**
* @author <a href="mailto:bruno@abstractj.org">Bruno Oliveira</a>
*/
public class SSSDException extends RuntimeException {
public SSSDException() {
}
public SSSDException(String message) {
super(message);
}
public SSSDException(String message, Throwable cause) {
super(message, cause);
}
}

View file

@ -94,19 +94,19 @@ public class Sssd {
InfoPipe infoPipe = infopipe(); InfoPipe infoPipe = infopipe();
attributes = infoPipe.getUserAttributes(username, Arrays.asList(attr)); attributes = infoPipe.getUserAttributes(username, Arrays.asList(attr));
} catch (Exception e) { } 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; return attributes;
} }
public List<String> getUserGroups() { public List<String> getUserGroups() {
List<String> userGroups = null; List<String> userGroups;
try { try {
InfoPipe infoPipe = Sssd.infopipe(); InfoPipe infoPipe = Sssd.infopipe();
userGroups = infoPipe.getUserGroups(username); userGroups = infoPipe.getUserGroups(username);
} catch (Exception e) { } 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; return userGroups;
} }