Created
June 24, 2017 05:00
-
-
Save Pushpalanka/e93257d93c0847d40ee39cd17ed6fab8 to your computer and use it in GitHub Desktop.
CustomClaimHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomClaimHandler implements ClaimHandler { | |
private static Log log = LogFactory.getLog(CustomClaimHandler.class); | |
private static volatile CustomClaimHandler instance; | |
private String connectionURL = null; | |
private String userName = null; | |
private String password = null; | |
private String jdbcDriver = null; | |
private String sql = null; | |
public static CustomClaimHandler getInstance() { | |
if (instance == null) { | |
synchronized (CustomClaimHandler.class) { | |
if (instance == null) { | |
instance = new CustomClaimHandler(); | |
} | |
} | |
} | |
return instance; | |
} | |
public Map<String, String> handleClaimMappings(StepConfig stepConfig, | |
AuthenticationContext context, Map<String, String> remoteAttributes, | |
boolean isFederatedClaims) throws FrameworkException { | |
String authenticatedUser = null; | |
if (stepConfig != null) { | |
//calling from StepBasedSequenceHandler | |
authenticatedUser = stepConfig.getAuthenticatedUser(); | |
} else { | |
//calling from RequestPathBasedSequenceHandler | |
authenticatedUser = context.getSequenceConfig().getAuthenticatedUser(); | |
} | |
Map<String, String> claims = handleLocalClaims(authenticatedUser, context); | |
claims.putAll(handleExternalClaims(authenticatedUser)); | |
return claims; | |
} | |
/** | |
* @param context | |
* @return | |
* @throws FrameworkException | |
*/ | |
protected Map<String, String> handleLocalClaims(String authenticatedUser, | |
AuthenticationContext context) throws FrameworkException { | |
.... | |
} | |
private Map<String, String> getFilteredAttributes(Map<String, String> allAttributes, | |
Map<String, String> requestedClaimMappings, boolean isStandardDialect) { | |
.... | |
} | |
protected String getDialectUri(String clientType, boolean claimMappingDefined) { | |
.... | |
} | |
/** | |
* Added method to retrieve claims from external sources. This results will be merged to the local claims when | |
* returning final claim list, to be added to the SAML response, that is sent back to the SP. | |
* | |
* @param authenticatedUser : The user for whom we require claim values | |
* @return | |
*/ | |
private Map<String, String> handleExternalClaims(String authenticatedUser) throws FrameworkException { | |
Map<String, String> externalClaims = new HashMap<String, String>(); | |
externalClaims.put("http://pushpalanka.org/claims/keplerNumber","E90836W19881010"); | |
externalClaims.put("http://pushpalanka.org/claims/status","active"); | |
return externalClaims; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment