Created
July 7, 2021 06:12
-
-
Save athiththan11/13c58af368041c54c2abb665fccf673f to your computer and use it in GitHub Desktop.
Extended JIT Provisioning Handler to assign Roles in WSO2 API Manager
This file contains hidden or 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
package com.sample.handlers; | |
import java.util.List; | |
import java.util.Map; | |
import org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException; | |
import org.wso2.carbon.identity.application.authentication.framework.handler.provisioning.impl.SystemRolesRetainedProvisionHandler; | |
import org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants; | |
/** | |
* The handler extends the implementation of SystemRolesRetainedProvisionHandler | |
* which is used to retain the Roles during the provisioning process without | |
* removing them. | |
* | |
* If you want this handler in lower versions of API Manager (2.x), extend | |
* DefaultProvisioningHandler | |
*/ | |
public class JITRoleProvisioningHandler extends SystemRolesRetainedProvisionHandler { | |
@Override | |
public void handle(List<String> roles, String subject, Map<String, String> attributes, | |
String provisioningUserStoreId, String tenantDomain) throws FrameworkException { | |
/** | |
* Filter and assign roles based on the IDP configurations. The attributes map | |
* contains an entry for the IDP name, that is used for federation. | |
* | |
* If you are having multiple federated IDPs, then you can conditionally assign | |
* the required roles to the provisioning users. | |
*/ | |
// String idp = attributes.get(FrameworkConstants.IDP_ID); | |
// if ("ExternalIDP".equals(idp)) { | |
// roles.add("Internal/subscriber"); | |
// roles.add("custom_role"); | |
// } | |
// add the roles | |
roles.add("Internal/subscriber"); | |
super.handle(roles, subject, attributes, provisioningUserStoreId, tenantDomain); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment