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.