4351. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:51:30 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

4351.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:30 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-web\src\main\java\gov\va\nvap\web\util FieldChecks.java Fri Apr 21 20:03:30 2017 UTC

4351.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 464
Removed 0 0

4351.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

4351.4 Active regular expressions

No regular expressions were active.

4351.5 Comparison detail

        1   package go v.va.nvap. web.util;
        2  
        3   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        4   import gov .va.nvap.p rivacy.Con sentDirect iveReferen ceType;
        5   import gov .va.nvap.w eb.util.da te.DateUti l;
        6  
        7   import jav a.text.Mes sageFormat ;
        8   import jav a.text.Par seExceptio n;
        9   import jav a.text.Sim pleDateFor mat;
        10   import jav a.util.Arr ayList;
        11   import jav a.util.Cal endar;
        12   import jav a.util.Dat e;
        13   import jav a.util.Has hMap;
        14   import jav a.util.Ite rator;
        15   import jav a.util.Map ;
        16   import jav a.util.Pro pertyResou rceBundle;
        17   import jav a.util.Res ourceBundl e;
        18  
        19   import jav ax.servlet .http.Http ServletReq uest;
        20   import jav ax.servlet .http.Http Session;
        21  
        22   import org .apache.co mmons.vali dator.Arg;
        23   import org .apache.co mmons.vali dator.Fiel d;
        24   import org .apache.co mmons.vali dator.Gene ricValidat or;
        25   import org .apache.co mmons.vali dator.Vali datorActio n;
        26   import org .apache.co mmons.vali dator.util .Validator Utils;
        27  
        28   /**
        29    * Validat or for che cking fiel ds.
        30    * 
        31    * @author  David Vaz quez Modif ied By: As ha Amritra j
        32    */
        33   public cla ss FieldCh ecks {
        34           /* *
        35            *  Add the l ist of err or message s to the l ist.
        36            * /
        37           st atic priva te void ad dMessage(f inal Field  field,
        38                             final  ValidatorA ction acti on,
        39                             final  ArrayList< ValidatorM essage> me ssages) {
        40                    fina l Property ResourceBu ndle prb =  (Property ResourceBu ndle) Reso urceBundle
        41                                      .getBund le("gov.va .nvap.web. applicatio n");
        42                    fina l Arg[] ar gs = field .getArgs(" ");
        43                    fina l String[]  messageAr gs = new S tring[args .length];
        44                    int  i = 0;
        45                    for  (final Arg  arg : arg s) {
        46                             messag eArgs[i++]  = prb.get String(arg .getKey()) ;
        47                    }
        48                    fina l Validato rMessage m essage = n ew Validat orMessage( );
        49                    mess age.setPro perty(fiel d.getPrope rty());
        50                    mess age.setMes sage(Messa geFormat.f ormat(prb. getString( action.get Msg()),
        51                                      (Object[ ]) message Args));
        52                    mess ages.add(m essage);
        53           }
        54  
        55           /* *
        56            *  Validate  date patte rn.
        57            * /
        58           st atic publi c boolean  validateDa te(final O bject bean , final Fi eld field,
        59                             final  ValidatorA ction acti on, final  HttpServle tRequest r equest,
        60                             final  ArrayList< ValidatorM essage> me ssages) {
        61                    bool ean ret;
        62                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        63                                      field.ge tProperty( ));
        64                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        65  
        66                    ret  = GenericV alidator.i sBlankOrNu ll(value)
        67                                      || (!Gen ericValida tor.isBlan kOrNull(da tePattern)  && Generi cValidator
        68                                                       .i sDate(valu e, datePat tern, fals e));
        69  
        70                    if ( !ret) {
        71                             FieldC hecks.addM essage(fie ld, action , messages );
        72                    }
        73  
        74                    retu rn ret;
        75           }
        76  
        77           /* *
        78            *  Validate  if the sta rt and end  dates are  correct.
        79            * /
        80           st atic publi c boolean  validateDa teAfter(fi nal Object  bean,
        81                             final  Field fiel d, final V alidatorAc tion actio n,
        82                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        83                    bool ean ret =  false;
        84                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        85                                      field.ge tProperty( ));
        86                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        87                    fina l String d ateField =  field.get VarValue(" dateField" );
        88  
        89                    if ( !GenericVa lidator.is BlankOrNul l(value))  {
        90                             if (!G enericVali dator.isBl ankOrNull( datePatter n)
        91                                               && !Generi cValidator .isBlankOr Null(dateF ield)) {
        92                                      final St ring dateF ieldValue  = Validato rUtils.get ValueAsStr ing(
        93                                                       be an, dateFi eld);
        94                                      if (!Gen ericValida tor.isBlan kOrNull(da teFieldVal ue)) {
        95                                               if (Generi cValidator .isDate(va lue, dateP attern, fa lse)
        96                                                                && G enericVali dator.isDa te(dateFie ldValue,
        97                                                                                  datePatt ern, false )) {
        98                                                       fi nal Simple DateFormat  formatter  = new Sim pleDateFor mat(
        99                                                                         datePa ttern);
        100                                                       tr y {
        101                                                                fina l Date d1  = formatte r.parse(va lue);
        102                                                                fina l Date d2  = formatte r.parse(da teFieldVal ue);
        103                                                                // A dded check  not to re turn error  if the st art/end
        104                                                                // d ates are t he same
        105                                                                if ( d1.equals( d2)) {
        106                                                                         ret =  true;
        107                                                                } el se {
        108                                                                         ret =  d1.after(d 2);
        109                                                                }
        110                                                       }  catch (fin al Throwab le t) {
        111                                                       }
        112                                               }
        113                                      } else {
        114                                               ret = true ;
        115                                      }
        116                             }
        117                    } el se {
        118                             ret =  true;
        119                    }
        120  
        121                    if ( !ret) {
        122                             FieldC hecks.addM essage(fie ld, action , messages );
        123                    }
        124  
        125                    retu rn ret;
        126           }
        127  
        128           st atic publi c boolean  validateDa teAfterAut horization AndBeforeE xpiration(
        129                             final  Object bea n, final F ield field , final Va lidatorAct ion action ,
        130                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        131                    bool ean ret =  false;
        132                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        133                                      field.ge tProperty( ));
        134                    fina l String c onsentType  = Validat orUtils.ge tValueAsSt ring(bean,
        135                                      "consent Type");
        136                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        137  
        138                    if ( "NwHIN Org anization  Restrictio n Revocati on".equals (consentTy pe)) {
        139                             return  true;
        140                    }
        141  
        142                    if ( !GenericVa lidator.is BlankOrNul l(value))  {
        143                             if (!G enericVali dator.isBl ankOrNull( datePatter n)) {
        144                                      final Si mpleDateFo rmat forma tter = new  SimpleDat eFormat(
        145                                                       da tePattern) ;
        146                                      try {
        147                                               final Date  d1 = form atter.pars e(value);
        148                                               final Date  fieldDate  = DateUti l.voidTime (d1);
        149                                               final Http Session se ssion = re quest.getS ession(fal se);
        150                                               final Cons entDirecti veReferenc eType refe rence = (C onsentDire ctiveRefer enceType)  getConsent DirectiveT ype(
        151                                                                sess ion, conse ntType);
        152                                               if (NullCh ecker.isNo tEmpty(ref erence)) {
        153                                                       Da te authori zationDate  = referen ce.getOpti nDate();
        154                                                       au thorizatio nDate = Da teUtil
        155                                                                         .voidT ime(author izationDat e);
        156                                                       Da te expirat ionDate =  reference. getExpirat ionDate();
        157                                                       ex pirationDa te = DateU til.voidTi me(expirat ionDate);
        158                                                       if  (fieldDat e.after(au thorizatio nDate)
        159                                                                         && fie ldDate.bef ore(expira tionDate))  {
        160                                                                ret  = true;
        161                                                       }  else if (f ieldDate.e quals(auth orizationD ate)) {
        162                                                                ret  = true;
        163                                                       }  else {
        164                                                                ret  = false;
        165                                                       }
        166                                               }
        167  
        168                                      } catch  (final Par seExceptio n ex) {
        169                                      }
        170                             }
        171                    } el se {
        172                             ret =  true;
        173                    }
        174  
        175                    if ( !ret) {
        176                             FieldC hecks.addM essage(fie ld, action , messages );
        177                    }
        178                    retu rn ret;
        179           }
        180  
        181           st atic publi c ConsentD irectiveRe ferenceTyp e getConse ntDirectiv eType(
        182                             HttpSe ssion sess ion, Strin g consentT ype) {
        183                    Obje ct consent DirectiveR eferenceOb j = null;
        184                    if ( "SSA Revoc ation".equ als(consen tType)) {
        185                             consen tDirective ReferenceO bj = sessi on
        186                                               .getAttrib ute("ssaCo nsentDirec tive");
        187                    } el se if ("Nw HIN Revoca tion".equa ls(consent Type)) {
        188                             consen tDirective ReferenceO bj = sessi on
        189                                               .getAttrib ute("conse ntDirectiv e");
        190                    } el se if ("Nw HIN Organi zation Res triction R evocation"
        191                                      .equals( consentTyp e)) {
        192                             consen tDirective ReferenceO bj = sessi on
        193                                               .getAttrib ute("nwhin Organizati onRestrict ionsDirect ive");
        194                    }
        195                    if ( ConsentDir ectiveRefe renceType. class
        196                                      .isInsta nce(consen tDirective ReferenceO bj)) {
        197                             final  ConsentDir ectiveRefe renceType  reference  = (Consent DirectiveR eferenceTy pe) consen tDirective ReferenceO bj;
        198                             return  reference ;
        199                    }
        200                    retu rn null;
        201           }
        202  
        203           st atic publi c boolean  validateDa teAfterAut horization (final Obj ect bean,
        204                             final  Field fiel d, final V alidatorAc tion actio n,
        205                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        206                    bool ean ret =  false;
        207                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        208                                      field.ge tProperty( ));
        209                    fina l String c onsentType  = Validat orUtils.ge tValueAsSt ring(bean,
        210                                      "consent Type");
        211                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        212  
        213                    if ( !GenericVa lidator.is BlankOrNul l(value))  {
        214                             if (!G enericVali dator.isBl ankOrNull( datePatter n)) {
        215                                      final Si mpleDateFo rmat forma tter = new  SimpleDat eFormat(
        216                                                       da tePattern) ;
        217                                      try {
        218                                               final Date  d1 = form atter.pars e(value);
        219                                               final Date  fieldDate  = DateUti l.voidTime (d1);
        220                                               final Http Session se ssion = re quest.getS ession(fal se);
        221                                               final Cons entDirecti veReferenc eType refe rence = (C onsentDire ctiveRefer enceType)  getConsent DirectiveT ype(
        222                                                                sess ion, conse ntType);
        223                                               if (NullCh ecker.isNo tEmpty(ref erence)) {
        224                                                       Da te authori zationDate  = referen ce.getOpti nDate();
        225                                                       au thorizatio nDate = Da teUtil
        226                                                                         .voidT ime(author izationDat e);
        227                                                       if  (fieldDat e.after(au thorizatio nDate)) {
        228                                                                ret  = true;
        229                                                       }  else if (f ieldDate.e quals(auth orizationD ate)) {
        230                                                                ret  = true;
        231                                                       }  else {
        232                                                                ret  = false;
        233                                                       }
        234                                               }
        235  
        236                                      } catch  (final Par seExceptio n ex) {
        237                                      }
        238                             }
        239                    } el se {
        240                             ret =  true;
        241                    }
        242  
        243                    if ( !ret) {
        244                             FieldC hecks.addM essage(fie ld, action , messages );
        245                    }
        246                    retu rn ret;
        247           }
        248  
        249           /* *
        250            *  Validate  if the dat e is befor e current  date.
        251            * /
        252           st atic publi c boolean  validateDa teBeforeNo w(final Ob ject bean,
        253                             final  Field fiel d, final V alidatorAc tion actio n,
        254                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        255                    bool ean ret =  false;
        256                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        257                                      field.ge tProperty( ));
        258                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        259  
        260                    if ( !GenericVa lidator.is BlankOrNul l(value))  {
        261                             if (!G enericVali dator.isBl ankOrNull( datePatter n)) {
        262                                      final Si mpleDateFo rmat forma tter = new  SimpleDat eFormat(
        263                                                       da tePattern) ;
        264                                      try {
        265                                               final Date  d1 = form atter.pars e(value);
        266                                               final Date  fieldDate  = DateUti l.voidTime (d1);
        267                                               final Date  now = Dat eUtil.void Time(new D ate());
        268                                               if (fieldD ate.before (now) || f ieldDate.e quals(now) ) {
        269                                                       re t = true;
        270                                               }
        271                                      } catch  (final Par seExceptio n ex) {
        272                                      }
        273                             }
        274                    } el se {
        275                             ret =  true;
        276                    }
        277  
        278                    if ( !ret) {
        279                             FieldC hecks.addM essage(fie ld, action , messages );
        280                    }
        281                    retu rn ret;
        282           }
        283  
        284           st atic publi c boolean  validateDa teWithinFi veYears(fi nal Object  bean,
        285                             final  Field fiel d, final V alidatorAc tion actio n,
        286                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        287                    fina l String c onsentType  = Validat orUtils.ge tValueAsSt ring(bean,
        288                                      "consent Type");
        289                    if ( !"NwHIN Au thorizatio n".equals( consentTyp e) && 
        290                                      !"NwHIN  Organizati on Restric tion Modif ication".e quals(cons entType) &
        291                                      !"NwHIN  Organizati on Restric tion Autho rization". equals(con sentType))  {
        292                             return  true;
        293                    }
        294                    
        295                    retu rn FieldCh ecks.valid ateDateWit hinNYears( bean, fiel d, action,
        296                                      request,  messages,  -5);
        297                    
        298           }
        299  
        300           st atic publi c boolean  validateOr ganization Required(f inal Objec t bean,
        301                             final  Field fiel d, final V alidatorAc tion actio n,
        302                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        303                    fina l String c onsentType  = Validat orUtils.ge tValueAsSt ring(bean,
        304                                      "consent Type");
        305                    
        306                    if ( !"NwHIN Or ganization  Restricti on Modific ation".equ als(consen tType) && 
        307                                      !"NwHIN  Organizati on Restric tion Autho rization". equals(con sentType))  {
        308                             return  true;
        309                    }
        310                    
        311                    retu rn FieldCh ecks.valid ateRequire d(bean, fi eld, actio n,
        312                             reques t, message s);
        313                    
        314           }
        315           
        316           st atic publi c boolean  validateDa teWithinNY ears(final  Object be an,
        317                             final  Field fiel d, final V alidatorAc tion actio n,
        318                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es,
        319                             int lo okbackYear s) {
        320                    bool ean ret =  false;
        321                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        322                                      field.ge tProperty( ));
        323                    fina l String d atePattern  = field.g etVarValue ("datePatt ern");
        324  
        325                    if ( !GenericVa lidator.is BlankOrNul l(value))  {
        326                             if (!G enericVali dator.isBl ankOrNull( datePatter n)) {
        327                                      final Si mpleDateFo rmat forma tter = new  SimpleDat eFormat(
        328                                                       da tePattern) ;
        329                                      try {
        330                                               final Date  d1 = form atter.pars e(value);
        331                                               final Date  fieldDate  = DateUti l.voidTime (d1);
        332                                               final Date  now = Dat eUtil.void Time(new D ate());
        333                                               final Cale ndar dateC al = Calen dar.getIns tance();
        334                                               dateCal.se tTime(now) ;
        335                                               // End dat e should b e 5 years  after begi n date
        336                                               dateCal.ad d(Calendar .YEAR, loo kbackYears );
        337                                               dateCal.ad d(Calendar .HOUR, 24) ;
        338                                               final Date  fiveYearB efore = da teCal.getT ime();
        339  
        340                                               // the oth er validat eDateBefor eNow will  catch the  date being
        341                                               // before  today or t oday
        342                                               if (fieldD ate.before (fiveYearB efore)) {
        343                                                       re t = false;
        344                                               } else {
        345                                                       re t = true;
        346                                               }
        347  
        348                                      } catch  (final Par seExceptio n ex) {
        349                                      }
        350                             }
        351                    } el se {
        352                             ret =  true;
        353                    }
        354  
        355                    if ( !ret) {
        356                             FieldC hecks.addM essage(fie ld, action , messages );
        357                    }
        358                    retu rn ret;
        359  
        360           }
        361  
        362           st atic publi c boolean  validateDa teWithinTw oYears(fin al Object  bean,
        363                             final  Field fiel d, final V alidatorAc tion actio n,
        364                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        365                    fina l String c onsentType  = Validat orUtils.ge tValueAsSt ring(bean,
        366                                      "consent Type");
        367                    if ( !"SSA Auth orization" .equals(co nsentType) ) {
        368                             return  true;
        369                    }
        370                    retu rn FieldCh ecks.valid ateDateWit hinNYears( bean, fiel d, action,
        371                                      request,  messages,  -2);
        372           }
        373  
        374           /* *
        375            *  Validate  SSN field.
        376            * /
        377           st atic publi c boolean  validateMa sk(final O bject bean , final Fi eld field,
        378                             final  ValidatorA ction acti on, final  HttpServle tRequest r equest,
        379                             final  ArrayList  messages)  {
        380                    bool ean ret;
        381                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        382                                      field.ge tProperty( ));
        383                    fina l String m ask = fiel d.getVarVa lue("mask" );
        384  
        385                    ret  = GenericV alidator.i sBlankOrNu ll(value)
        386                                      || (!Gen ericValida tor.isBlan kOrNull(ma sk) && Gen ericValida tor
        387                                                       .m atchRegexp (value, ma sk));
        388  
        389                    if ( !ret) {
        390                             FieldC hecks.addM essage(fie ld, action , messages );
        391                    }
        392  
        393                    retu rn ret;
        394           }
        395  
        396           /* *
        397            *  Validate  request id  associate d with the  session.
        398            * /
        399           st atic publi c boolean  validateRe questId(fi nal Object  bean,
        400                             final  Field fiel d, final V alidatorAc tion actio n,
        401                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        402                    bool ean ret =  true;
        403                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        404                                      field.ge tProperty( ));
        405                    fina l HttpSess ion sessio n = reques t.getSessi on(false);
        406                    fina l String s essionAttr ibute = fi eld.getVar Value("ses sionAttrib ute");
        407  
        408                    if ( session !=  null) {
        409                             final  String req uestId = ( String) se ssion
        410                                               .getAttrib ute(sessio nAttribute );
        411                             ret =  !GenericVa lidator.is BlankOrNul l(value)
        412                                               && value.e quals(requ estId);
        413                    }
        414  
        415                    if ( !ret) {
        416                             FieldC hecks.addM essage(fie ld, action , messages );
        417                    }
        418  
        419                    retu rn ret;
        420           }
        421  
        422           /* *
        423            *  Validate  required f ields.
        424            * /
        425           st atic publi c boolean  validateRe quired(fin al Object  bean,
        426                             final  Field fiel d, final V alidatorAc tion actio n,
        427                             final  HttpServle tRequest r equest, fi nal ArrayL ist messag es) {
        428                    bool ean ret;
        429                    fina l String v alue = Val idatorUtil s.getValue AsString(b ean,
        430                                      field.ge tProperty( ));
        431  
        432                    ret  = !Generic Validator. isBlankOrN ull(value) ;
        433  
        434                    if ( !ret) {
        435                             FieldC hecks.addM essage(fie ld, action , messages );
        436                    }
        437  
        438                    retu rn ret;
        439           }
        440  
        441           /* *
        442            *  Checks fi elds if th ey are not  null or e mpty for j sp, if so,  replace w ith
        443            *  non-delim inated spa ce for aes thetics
        444            * /
        445           st atic publi c Map<Stri ng, Object > replaceE mptyOrNull WithSpace(
        446                             final  Map<String , Object>  inList) {
        447                    // i terate ove r all keys , check va lue of eac h key, loo king for n ull or
        448                    // e mpty
        449                    // i f find one , replace  with non-d eliminated  space
        450                    Map< String, Ob ject> outL ist = new  HashMap<St ring, Obje ct>();
        451                    Iter ator<Strin g> i = inL ist.keySet ().iterato r();
        452                    Stri ng tempKey ;
        453                    whil e (i.hasNe xt()) {
        454                             tempKe y = i.next ();
        455                             if (Nu llChecker. isNullOrEm pty(inList .get(tempK ey))) {
        456                                      outList. put(tempKe y, " ");
        457                             } else  {
        458                                      outList. put(tempKe y, inList. get(tempKe y));
        459                             }
        460                    }
        461                    retu rn outList ;
        462           }
        463  
        464   }