/**
  * Add new user into local db.
  *
  * @param securedUser user
  */
 @Transactional
 public void addNewUserIntoLocal(SecuredUser securedUser) {
   User user = securedUser.getUser();
   user.setAuthProviderClass(securedUser.getUserInfoProviderClass());
   user.setCreatedDate(new Date());
   User newUser = userService.getUserById(user.getUserId());
   if (newUser != null) {
     user = newUser.merge(user);
   }
   if (user.getRole() == null) {
     user.setRole(Role.USER);
   }
   User savedUser = userService.saveUser(user);
   securedUser.setUser(savedUser);
 }
 @Override
 public User loadUser(final String userId) {
   Map<String, String> map = SiteMinderFilter.threadStorage.get();
   User user = null;
   if (map != null) {
     user = new User();
     user.setUserId(userId);
     user.setUserName(getString(map, "name", ""));
     user.setEmail(getString(map, "email", ""));
     user.setMobilePhone(getString(map, "cellphone", ""));
     user.setAuthProviderClass(SiteminderSSOPlugin.this.getClass().getName());
     user.setEnabled(true);
     user.setExternal(true);
     user.setRole(Role.USER);
     SiteMinderFilter.threadStorage.remove();
   }
   return user;
 }