0
votes

I'm writing a simple custom user store manager for wso2is.

this is the code:

public class CustomJDBCUserStoreManager extends JDBCUserStoreManager {
    private static Log log = LogFactory.getLog(CustomJDBCUserStoreManager.class);

    public CustomJDBCUserStoreManager() {
    }

    public CustomJDBCUserStoreManager(org.wso2.carbon.user.api.RealmConfiguration realmConfig,
                              Map<String, Object> properties,
                              ClaimManager claimManager,
                              ProfileConfigurationManager profileManager,
                              UserRealm realm, Integer tenantId)
    throws UserStoreException {
        super(realmConfig, properties, claimManager, profileManager, realm, tenantId, false);
    }

    @Override
    public void doAddUser(String userName, Object credential, String[] roleList,
                      Map<String, String> claims, String profileName,
                      boolean requirePasswordChange) throws UserStoreException {


        String[] users = super.doListUsers( "*", -1);

        int nUser = users.length;

        if (nUser > 5){
            throw new UserStoreException( "Reached the maximum number of global users" );
        }else{
            super.doAddUser( userName, credential, roleList, claims, profileName, requirePasswordChange );
        }

    }

}

The code work. When i try to insert from interface a number of user > 5, the interface give me the Exception message "Reached the maximum number of global users".

But when I try to add a user by SCIM over the 5 user I have the message:

{"Errors":[{"description":"Error in adding the user: mrossi to the user store..","code":"500"}]}

Well, in this point I need to get the correct message exception "Reached the maximum number of global users" and not a generic message "Error in adding the user".

Is there a way to do it?

thanks.

3

3 Answers

1
votes

If you have problems with building particular component. You can try it [a] Identity Server next release.

build it with maven and you can find distribution inside "product-is/modules/distribution/target".

[a] https://github.com/wso2/product-is/

0
votes

You need to do little code modification to SCIM provider component. What is the version of WSO2 Identity Server you are using so that I can point you

0
votes

Please refer below link [1]. In SCIMUserManager class line 159 change "Error in adding the user: " + user.getUserName() + " to the user store.." to e.getMessage() and replace wso2.war in repository/deployment/server/webapps also delete wso2 directory

[1] https://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/identity/org.wso2.carbon.identity.scim.provider/4.2.2/src/main/java/org/wso2/carbon/identity/scim/provider/impl