private NavigationElementTree convert(NavigationElement navigationElement) {
   NavigationElementTree navigationElementTree = new NavigationElementTree();
   String name = navigationElement.getName();
   if (navigationElement.getTextResourceVersion() != null) {
     name = navigationElement.getTextResourceVersion().getText();
   }
   navigationElementTree.setName(name);
   navigationElementTree.setUrlPath(navigationElement.getUrlPath());
   navigationElementTree.setPageUrl(navigationElement.getPageUrl());
   navigationElementTree.setElementType(navigationElement.getElementType());
   navigationElementTree.setPath(navigationElement.getPath());
   navigationElementTree.setLookup(navigationElement.getLookup());
   navigationElementTree.setSortPosition(navigationElement.getSortPosition());
   navigationElementTree.setChildren(new ArrayList<NavigationElementTree>());
   navigationElementTree.setAllowDrag(false);
   navigationElementTree.setAllowDrop(false);
   navigationElementTree.setExpandable(true);
   navigationElementTree.setExpanded(false);
   navigationElementTree.setHidden(
       navigationElement.getHidden() != null && navigationElement.getHidden());
   return navigationElementTree;
 }
  @Override
  public void execute(
      Map<String, String> map,
      HttpServletRequest request,
      HttpServletResponse response,
      NavigationElement currentNavigationElement) {
    if (currentNavigationElement != null
        && currentNavigationElement.getPageUrl().equals(getLoginPageUrl())) {
      try {
        KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
        KeyPair pair = kpg.generateKeyPair();

        String publicKey = new Base64Encoder().encode(pair.getPublic().getEncoded());
        map.put("publicKey", "'" + publicKey.replaceAll("\n", "") + "'");

        HttpSession session = request.getSession();
        session.setAttribute(
            OpenFlameSecurityConstants.PASSWORD_ENCRYPTED_PRIVATE_KEY, pair.getPrivate());
      } catch (NoSuchAlgorithmException e) {
        logger.error(
            "Can't generate private/public keys for sign on process.\n" + e.getMessage(), e);
      }
    }
  }