public IdentityMgtEventListener() {

    module = IdentityMgtConfig.getInstance().getIdentityDataStore();
    String adminUserName =
        IdentityMgtServiceComponent.getRealmService()
            .getBootstrapRealmConfiguration()
            .getAdminUserName();
    try {
      IdentityMgtConfig config = IdentityMgtConfig.getInstance();

      // Get the policy registry with the loaded policies.
      policyRegistry = config.getPolicyRegistry();

      if (config.isListenerEnable()) {

        UserStoreManager userStoreMng =
            IdentityMgtServiceComponent.getRealmService().getBootstrapRealm().getUserStoreManager();
        if (!userStoreMng.isReadOnly()) {

          userStoreMng.setUserClaimValue(
              adminUserName, UserIdentityDataStore.ACCOUNT_LOCK, Boolean.toString(false), null);
        }
      }
    } catch (UserStoreException e) {
      log.error("Error while init identity listener", e);
    }
  }
  public void doClaimStuff() throws Exception {
    UserStoreManager usWriter = realm.getUserStoreManager();
    String[] allClaims = {
      ClaimTestUtil.CLAIM_URI1, ClaimTestUtil.CLAIM_URI2, ClaimTestUtil.CLAIM_URI3
    };

    // add DEFAULT
    usWriter.setUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, "claim1default", null);
    try {
      usWriter.setUserClaimValue(null, ClaimTestUtil.CLAIM_URI1, "claim1default", null);
      fail("Exception at set claim values to null users");
    } catch (Exception e) {
      // expected exception
      if (log.isDebugEnabled()) {
        log.debug("Expected error, hence ignored", e);
      }
    }
    try {
      usWriter.setUserClaimValue("isuru", null, "claim1default", null);
      fail("Exception at set claim values to null claimURI");
    } catch (Exception e) {
      // expected exception
      if (log.isDebugEnabled()) {
        log.debug("Expected error, hence ignored", e);
      }
    }
    try {
      usWriter.setUserClaimValue("isuru", ClaimTestUtil.CLAIM_URI1, null, null);
      fail("Exception at set claim values to null claimValue");
    } catch (Exception e) {
      // expected exception
      if (log.isDebugEnabled()) {
        log.debug("Expected error, hence ignored", e);
      }
    }

    String value = usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, null);
    assertEquals("claim1default", value);
    // Non existing user
    String value1 = usWriter.getUserClaimValue("isuru", ClaimTestUtil.CLAIM_URI1, null);
    assertEquals(null, value1);
    // update default
    usWriter.setUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, "dimzi lee", null);
    value = usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, null);
    assertEquals("dimzi lee", value);

    // multiple additions
    Map<String, String> map = new HashMap<String, String>();
    map.put(ClaimTestUtil.CLAIM_URI1, "lee");
    map.put(ClaimTestUtil.CLAIM_URI3, "muthu");

    usWriter.setUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI2, "claim2default", null);
    assertEquals(
        "dimzi lee", usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, null));
    assertEquals(
        "claim2default", usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI2, null));
    assertNull(usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI3, null));

    usWriter.setUserClaimValues("dimuthu", map, ClaimTestUtil.HOME_PROFILE_NAME);
    assertEquals(
        "lee",
        usWriter.getUserClaimValue(
            "dimuthu", ClaimTestUtil.CLAIM_URI1, ClaimTestUtil.HOME_PROFILE_NAME));
    assertNull(
        usWriter.getUserClaimValue(
            "dimuthu", ClaimTestUtil.CLAIM_URI2, ClaimTestUtil.HOME_PROFILE_NAME));
    assertEquals(
        "muthu",
        usWriter.getUserClaimValue(
            "dimuthu", ClaimTestUtil.CLAIM_URI3, ClaimTestUtil.HOME_PROFILE_NAME));

    usWriter.setUserClaimValue(
        "dimuthu",
        UserCoreConstants.PROFILE_CONFIGURATION,
        ClaimTestUtil.HOME_PROFILE_NAME,
        ClaimTestUtil.HOME_PROFILE_NAME);
    Map<String, String> obtained =
        usWriter.getUserClaimValues("dimuthu", allClaims, ClaimTestUtil.HOME_PROFILE_NAME);
    // assertNull(obtained.get(ClaimTestUtil.CLAIM_URI1)); // hidden
    // assertEquals("claim2default", obtained.get(ClaimTestUtil.CLAIM_URI2)); // overridden
    assertEquals("muthu", obtained.get(ClaimTestUtil.CLAIM_URI3)); // normal

    // UPDATE
    map.put(ClaimTestUtil.CLAIM_URI3, "muthulee");
    usWriter.setUserClaimValues("dimuthu", map, ClaimTestUtil.HOME_PROFILE_NAME);
    value =
        usWriter.getUserClaimValue(
            "dimuthu", ClaimTestUtil.CLAIM_URI3, ClaimTestUtil.HOME_PROFILE_NAME);
    assertEquals("muthulee", value);

    // DELETE
    usWriter.deleteUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, null);
    value = usWriter.getUserClaimValue("dimuthu", ClaimTestUtil.CLAIM_URI1, null);
    assertNull(value);
    try {
      usWriter.deleteUserClaimValue("dimuthu", null, null);
      fail("Exception at null Claim URI");
    } catch (Exception e) {
      // expected exception
      if (log.isDebugEnabled()) {
        log.debug("Expected error, hence ignored", e);
      }
    }
    try {
      usWriter.deleteUserClaimValue(null, ClaimTestUtil.CLAIM_URI1, null);
      fail("Exception at giving null user name to delete user claim values");
    } catch (Exception e) {
      // expected exception
      if (log.isDebugEnabled()) {
        log.debug("Expected error, hence ignored", e);
      }
    }

    usWriter.deleteUserClaimValues("dimuthu", allClaims, ClaimTestUtil.HOME_PROFILE_NAME);
    obtained = usWriter.getUserClaimValues("dimuthu", allClaims, ClaimTestUtil.HOME_PROFILE_NAME);
    assertNull(obtained.get(ClaimTestUtil.CLAIM_URI2)); // overridden
    assertNull(obtained.get(ClaimTestUtil.CLAIM_URI3));

    // UserStoreManager admin = realm.getUserStoreManager();
    // admin.deleteUser("dimuthu");
  }