public void validateLoginInformation(Object obj, Errors errors) {
   SsUsr ssUser = (SsUsr) obj;
   if (!DataDictionaryValidator.validateLoginUserName(ssUser.getSsUsername(), true)) {
     errors.reject("loginWithUsername.no.username");
   }
   if (!DataDictionaryValidator.validateLoginPassword(ssUser.getSsPassword(), true)) {
     errors.reject("loginWithUsername.no.password");
   }
 }
Example #2
0
  protected ModelAndView onSubmit(
      HttpServletRequest request,
      HttpServletResponse response,
      Object command,
      BindException errors)
      throws Exception {

    long user_id = 0;
    SsUsr ssUser = (SsUsr) command;
    Map<String, String> requestModel = new HashMap<String, String>();
    user_id =
        ssUserBusiness.findAndKeepUserByUNamePwd(ssUser.getSsUsername(), ssUser.getSsPassword());

    if (user_id != 0 && user_id != -1) {

      // requestModel.put(SSConstants.USER_ID, String.valueOf(user_id));
      request.getSession().setAttribute(SSConstants.USER_ID, user_id);
      ssUser.setUserId(String.valueOf(user_id));
      /**
       * added code to set authentication object for SS user Remove this code after integrating the
       * spring security in the SS Web
       */
      SecurityContext context = SecurityContextHolder.getContext();
      Authentication authentication = getAuthenticationObjectForSSUser(ssUser);
      context.setAuthentication(authentication);

      ModelAndView view = new ModelAndView(new RedirectView(SSConstants.CONTROLLER_DASHBOARD));
      return view;
    } else if (user_id == -1) {
      request.setAttribute(SSConstants.USER_WRONG_PWD, SSConstants.NO);
      return new ModelAndView(getSuccessView(), "ssUser", ssUser);
    } else {
      request.setAttribute(SSConstants.USER_AUTHORISATION, SSConstants.NO);
      return new ModelAndView(getSuccessView(), "ssUser", ssUser);
    }
  }
 public void validate(Object command, BindException errors, HttpServletRequest request) {
   SsUsr ssUser = (SsUsr) command;
   if (!DataDictionaryValidator.validateEmailAddress(ssUser.getSsEmail(), true)) {
     errors.reject("createAccount.loginInfo.no.email");
   }
   if (!DataDictionaryValidator.validateEmailAddress(ssUser.getSsReEmail(), true)) {
     errors.reject("createAccount.loginInfo.no.reEmail");
   }
   if (DataDictionaryValidator.validateEmailAddress(ssUser.getSsEmail(), true)
       && DataDictionaryValidator.validateEmailAddress(ssUser.getSsReEmail(), true)) {
     if (!ssUser.getSsEmail().equals(ssUser.getSsReEmail())) {
       errors.reject("createAccount.loginInfo.noMatch.email");
     }
   }
   if (!DataDictionaryValidator.validatePrefContact(ssUser.getSsPrefPhone(), true)) {
     errors.reject("createAccount.loginInfo.no.prefContact");
   }
   if (ssUser.getAgreeTerms() == null) {
     errors.reject("createAccount.loginInfo.no.agreeTerms");
   }
 }
Example #4
0
  private Authentication getAuthenticationObjectForSSUser(SsUsr ssUser) {
    final String _authSSUserName = ssUser.getUserId();
    final String _authSSUserPassword = ssUser.getSsPassword();
    Authentication authentication =
        new Authentication() {
          private static final long serialVersionUID = 7294132617680720212L;

          private GrantedAuthority[] ga;
          private InMemoryDaoUser user = getInMemoryDaoUser();

          @Override
          public String getName() {
            return null;
          }

          @Override
          public void setAuthenticated(boolean arg0) throws IllegalArgumentException {}

          @Override
          public boolean isAuthenticated() {
            return false;
          }

          @Override
          public Object getPrincipal() {
            return user;
          }

          @Override
          public Object getDetails() {
            return null;
          }

          @Override
          public Object getCredentials() {
            return null;
          }

          @Override
          public GrantedAuthority[] getAuthorities() {
            return ga;
          }

          public InMemoryDaoUser getUser() {
            return user;
          }

          public void setUser(InMemoryDaoUser user) {
            this.user = user;
          }

          private InMemoryDaoUser getInMemoryDaoUser() {
            // setting authority
            GrantedAuthority[] ga = new GrantedAuthority[1];
            GrantedAuthority authority =
                new GrantedAuthority() {
                  @Override
                  public String getAuthority() {
                    return "SSAuth";
                  }
                };
            ga[0] = authority;
            this.ga = ga;

            InMemoryDaoUser user =
                new InMemoryDaoUser(
                    _authSSUserName, _authSSUserPassword, true, true, true, true, ga);
            user.setUserFunction(SSConstants.SS_USER_FUNCTION);

            return user;
          }
        };
    return authentication;
  }