1. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 4/23/2019 12:14:25 PM Central 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.

1.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\CCRS\CaseManagement-B6S3\CaseManagement-B6S3\ccrs_extensions\src\ccrs_ro\login\module CCRSCustomJAASCallBackModule.java Thu Mar 28 18:39:56 2019 UTC
2 C:\AraxisMergeCompare\Pri_re\CCRS\CaseManagement-B6S3\CaseManagement-B6S3\ccrs_extensions\src\ccrs_ro\login\module CCRSCustomJAASCallBackModule.java Wed Apr 17 03:03:54 2019 UTC

1.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 768
Changed 2 4
Inserted 0 0
Removed 0 0

1.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

1.4 Active regular expressions

No regular expressions were active.

1.5 Comparison detail

  1   /**
  2    * ccrs_ro .login.mod ule 
  3    * CCRSCus tomJAASCal lBackModul e.java
  4    * CCRSCus tomJAASCal lBackModul e
  5    * stuartb edoll
  6    * 8:05:14  AM
  7    * 2019
  8    *
  9    */
  10   package cc rs_ro.logi n.module;
  11  
  12   import jav a.rmi.Remo teExceptio n;
  13   import jav a.security .Principal ;
  14   import jav a.util.Enu meration;
  15   import jav a.util.Has htable;
  16   import jav a.util.Ite rator;
  17   import jav a.util.Lis t;
  18   import jav a.util.Map ;
  19   import jav a.util.Set ;
  20  
  21   import jav ax.securit y.auth.Sub ject;
  22   import jav ax.securit y.auth.cal lback.Call back;
  23   import jav ax.securit y.auth.cal lback.Call backHandle r;
  24   import jav ax.securit y.auth.cal lback.Name Callback;
  25   import jav ax.securit y.auth.cal lback.Pass wordCallba ck;
  26   import jav ax.securit y.auth.log in.LoginEx ception;
  27   import jav ax.securit y.auth.spi .LoginModu le;
  28   import jav ax.servlet .http.Http ServletReq uest;
  29  
  30   import com .ibm.websp here.secur ity.Custom RegistryEx ception;
  31   import com .ibm.websp here.secur ity.EntryN otFoundExc eption;
  32   import com .ibm.websp here.secur ity.UserRe gistry;
  33   import com .ibm.websp here.secur ity.WSSecu rityExcept ion;
  34   import com .ibm.websp here.secur ity.auth.c allback.WS CredTokenC allbackImp l;
  35   import com .ibm.websp here.secur ity.auth.c allback.WS RealmNameC allbackImp l;
  36   import com .ibm.websp here.secur ity.cred.W SCredentia l;
  37   import com .ibm.wsspi .security. auth.callb ack.WSAppC ontextCall back;
  38   import com .ibm.wsspi .security. auth.callb ack.WSServ letRequest Callback;
  39   import com .ibm.wsspi .security. token.Attr ibuteNameC onstants;
  40  
  41   import ccr s_ro.commo n.authenti cation.CCR SIAMPrinci pal;
  42   import ccr s_ro.commo n.logger.C CRS_RO_Log ger;
  43   import ccr s_ro.commo n.logger.L oggerInter face;
  44  
  45   /**
  46    * @author  stuartbed oll
  47    *
  48    */
  49  
  50   public cla ss CCRSCus tomJAASCal lBackModul e implemen ts LoginMo dule {
  51  
  52           pr otected Ma p<String,  ?> _shared State;
  53           pr otected Su bject _sub ject = nul l;
  54           pr otected Ca llbackHand ler _callb ackHandler ;
  55           pr otected CC RSIAMPrinc ipal iamPr incipal;
  56           
  57           pr ivate Stri ng usernam e;
  58  
  59           pr ivate fina l String c ustomPriva teCredenti al = "Cust omLoginMod uleCredent ial";
  60  
  61           WS Credential  credentia l = null;
  62           pr ivate stat ic final L oggerInter face logge r = CCRS_R O_Logger.s ingleton() ;
  63  
  64           /* *
  65            *  Initializ ation of l ogin modul e
  66            * /
  67           pu blic void  initialize (Subject s ubject, Ca llbackHand ler callba ckHandler,  Map<Strin g, ?> shar edState,
  68                             Map<St ring, ?> o ptions) {
  69                    fina l String m ethodName  = "initial ize";
  70                    logg er.traceEn try(this,  methodName );
  71                    _sha redState =  sharedSta te;
  72                    _sub ject = sub ject;
  73                    _cal lbackHandl er = callb ackHandler ;
  74                    user name = "ru ruser";
  75           }
  76  
  77           pu blic boole an login()  throws Lo ginExcepti on {
  78                    fina l String m ethodName  = "login";
  79                    logg er.traceEn try(this,  methodName );
  80           bo olean succ ess = fals e;
  81                    char  passwordC har[] = nu ll;
  82                    byte [] credTok en = null;
  83                    Http ServletReq uest reque st = null;
  84                    // H ttpServlet Response r esponse =  null;
  85                    Map  appContext  = null;
  86                    Stri ng realm =  null;
  87                    // S tring auth MechOid =  null;
  88                    // j ava.securi ty.cert.X5 09Certific ate[] cert Chain = nu ll;
  89  
  90                    Name Callback n ameCallbac k = null;
  91                    Pass wordCallba ck passwor dCallback  = null;
  92                    WSCr edTokenCal lbackImpl  wsCredToke nCallback  = null;
  93                    WSSe rvletReque stCallback  wsServlet RequestCal lback = nu ll;
  94                    // W SServletRe sponseCall back wsSer vletRespon seCallback  = null;
  95                    WSAp pContextCa llback wsA ppContextC allback =  null;
  96                    WSRe almNameCal lbackImpl  wsRealmNam eCallback  = null;
  97                    // W SX509Certi ficateChai nCallback  wsX509Cert ificateCal lback = nu ll;
  98                    // W SAuthMechO idCallback Impl wsAut hMechOidCa llback = n ull;
  99  
  100                    Call back[] cal lbacks = n ew Callbac k[6];
  101                    call backs[0] =  nameCallb ack = new  NameCallba ck("Userna me: ");
  102                    call backs[1] =  passwordC allback =  new Passwo rdCallback ("Password : ", false );
  103                    call backs[2] =  wsCredTok enCallback  = new WSC redTokenCa llbackImpl ("Credenti al Token:  ");
  104                    call backs[3] =  wsServlet RequestCal lback = ne w WSServle tRequestCa llback("Ht tpServletR equest: ") ;
  105                    // c allbacks[4 ] = wsServ letRespons eCallback  = new
  106                    // W SServletRe sponseCall back("Http ServletRes ponse: ");
  107                    call backs[4] =  wsAppCont extCallbac k = new WS AppContext Callback(" Applicatio nContextCa llback: ") ;
  108                    call backs[5] =  wsRealmNa meCallback  = new WSR ealmNameCa llbackImpl ("Realm na me:");
  109                    // c allbacks[7 ] = wsX509 Certificat eCallback  = new
  110                    // W SX509Certi ficateChai nCallback( "X509Certi ficate[]:  ");
  111                    // c allbacks[8 ] = wsAuth MechOidCal lback = ne w
  112                    // W SAuthMechO idCallback Impl("Auth MechOid: " );
  113                    // c allbacks[3 ] = wsToke nHolderCal lback = ne w WSTokenH olderCallb ack ("Auth z
  114                    // T oken List:  ");
  115  
  116                    try  {
  117                             // Get s the SHAR ED STATE i nformation
  118  
  119                             creden tial = (WS Credential ) _sharedS tate
  120                                               .get(com.i bm.wsspi.s ecurity.au th.callbac k.Constant s.WSCREDEN TIAL_KEY);
  121  
  122                             try {
  123                                      _callbac kHandler.h andle(call backs);
  124                             } catc h (Excepti on e) {
  125                                      // handl e exceptio n
  126                             }
  127  
  128   //                        if (na meCallback  != null)  {
  129   //                                 username  = nameCal lback.getN ame();
  130   //                                 logger.i nfo("nameC allback no t null nam e=" + user name);
  131   //                        }
  132   //
  133   //                        if (pa sswordCall back != nu ll) {
  134   //                                 password Char = pas swordCallb ack.getPas sword();
  135   //                                 logger.i nfo("passw ordCallbac k not null  name=" +  passwordCh ar);
  136   //
  137   //                        }
  138   //
  139   //                        if (ws CredTokenC allback !=  null) {
  140   //                                 credToke n = wsCred TokenCallb ack.getCre dToken();
  141   //                                 logger.i nfo("wsCre dTokenCall back not n ull name="  + credTok en);
  142   //                        }
  143  
  144                             if (ws ServletReq uestCallba ck != null ) {
  145                                      request  = wsServle tRequestCa llback.get HttpServle tRequest() ;
  146                                      if (requ est != nul l) {
  147                                               logger.inf o("wsServl etRequestC allback no t null hea ders=" + r equest.get HeaderName s());
  148                                               Enumeratio n<String>  headers =  request.ge tHeaderNam es();
  149                                               for (Enume ration<Str ing> e = h eaders; e. hasMoreEle ments();)  {
  150                                                       lo gger.info( "header: "  + e.nextE lement());
  151                                               }
  152                                      }
  153                                      username  = request .getHeader ("HTTP_ADS AMACCOUNTN AME");
  154                                      logger.i nfo("HTTP_ ADSAMACCOU NTNAME ="  + username );
  155                                      if (user name != nu ll && !use rname.isEm pty()) {
  156                                               success =  true;
  157                                      }else {
  158                                               success =  false;
  159                                      }
  160                             }
  161  
  162                             // if  (wsServlet ResponseCa llback !=  null) {
  163                             // res ponse = ws ServletRes ponseCallb ack.getHtt pServletRe sponse();
  164                             // log ger.info(" wsServletR esponseCal lback not  null
  165                             // hea ders="+res ponse.getH eaderNames ());
  166                             // }
  167  
  168                             if (ws AppContext Callback ! = null) {
  169                                      appConte xt = wsApp ContextCal lback.getC ontext();
  170                                      logger.i nfo("wsApp ContextCal lback not  null name= " + appCon text);
  171                             }
  172  
  173                             if (ws RealmNameC allback !=  null) {
  174                                      realm =  wsRealmNam eCallback. getRealmNa me();
  175                                      logger.i nfo("wsRea lmNameCall back not n ull name="  + realm);
  176                             }
  177  
  178                             // if  (wsX509Cer tificateCa llback !=  null) {
  179                             // cer tChain = w sX509Certi ficateCall back.getX5 09Certific ateChain() ;
  180                             // //l ogger.info ("wsX509Ce rtificateC allback no t null nam e="+certCh ain);
  181                             // }
  182                             //
  183                             // if  (wsAuthMec hOidCallba ck != null ) {
  184                             // aut hMechOid =  wsAuthMec hOidCallba ck.getAuth MechOid();
  185                             // //l ogger.info ("wsAuthMe chOidCallb ack not nu ll name="+ authMechOi d);
  186                             // }
  187                             // com .ibm.wsspi .security. common.aut h.module.I dentityAss ertionLogi nModule.st ate
  188                             String  mapKey =  "com.ibm.w sspi.secur ity.common .auth.modu le.Identit yAssertion LoginModul e.state";
  189                             Map<St ring, java .util.Hash table> myS haredState  = (Map<St ring, java .util.Hash table>) _s haredState ;
  190  
  191                             Hashta ble<String , Object>  customProp erties = n ew Hashtab le<String,  Object>() ;
  192                             // Has htable<Str ing, Objec t> credPro perties =  (java.util .Hashtable <String,
  193                             // Obj ect>)
  194                             // _sh aredState. get(Attrib uteNameCon stants.WSC REDENTIAL_ PROPERTIES _KEY);
  195                             // if  (customPro perties ==  null) {
  196                             // cus tomPropert ies = new  Hashtable< String, Ob ject>();
  197                             // }
  198                             /*
  199                              * Use r implemen ted login  module (tr ust valida tion) The  user imple mented log in
  200                              * mod ule perfor ms whateve r the user  requires  in trust v erificatio n. When tr ust
  201                              * is  verified,  the trust  verificati on status  and the lo gin identi ty must be  put
  202                              * int o a map in  the share  state of  the login  module, so  the crede ntial crea tion
  203                              * log in module  can use th e informat ion. Store  this map  in the fol lowing
  204                              * pro perty:
  205                              * 
  206                              * com .ibm.wsspi .security. common.aut h.module.I dentityAss ertionLogi nModule.st ate
  207                              * Thi s property  consists  of the fol lowing pro perties:
  208                              * 
  209                              * com .ibm.wsspi .security. common.aut h.module.I dentityAss ertionLogi nModule.
  210                              * tru sted Set t o true if  trusted an d false if  not trust ed.
  211                              * 
  212                              * com .ibm.wsspi .security. common.aut h.module.I denityAsse rtionLogin Module.
  213                              * pri ncipal Con tains the  principal  of the ide ntity.
  214                              * 
  215                              * com .ibm.wsspi .security. common.aut h.module.I dentityAss ertionLogi nModule.
  216                              * cer tificates  Contains t he certifi cate of th e identity .
  217                              */
  218                             // cus tomPropert ies.put("c om.ibm.wss pi.securit y.common.a uth.module .IdentityA ssertionLo ginModule. trusted",
  219                             // tru e);
  220                             Set<Pr incipal> p rincipals  = _subject .getPrinci pals();
  221                             
  222                             if (pr incipals ! = null &&  !principal s.isEmpty( )) {
  223                                      Iterator <Principal > itprin =  principal s.iterator ();
  224                                      logger.i nfo("login  principal s " + prin cipals.siz e());
  225  
  226                                      while (i tprin.hasN ext()) {
  227                                               Principal  principal  = itprin.n ext();
  228                                               logger.inf o("login p rincipal "  +principa l.getName( ));
  229                                      }
  230                             }else  {
  231                                      logger.i nfo("login  no princi pals " );
  232                             }
  233                             //CCRS IAMPrincip al iamPrin cipal = ne w CCRSIAMP rincipal(u sername);
  234                             // cus tomPropert ies.put("c om.ibm.wss pi.securit y.common.a uth.module .IdentityA ssertionLo ginModule. principal" ,
  235                             // iam Principal) ;
  236  
  237                             // Sam ple of cre ating cust om cache k ey
  238                             custom Properties .put(Attri buteNameCo nstants.WS CREDENTIAL _CACHE_KEY , "CCRS" +  username) ;
  239  
  240                             /*
  241                              * Sam ple for cr eating use r ID and s ecurity na me
  242                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_UNIQUE ID, "userI d");
  243                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_SECURI TYNAME,
  244                              * "se curityName ");
  245                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_REALM,  "realm");
  246                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_GROUPS ,
  247                              * "gr oupList");
  248                              */
  249  
  250                             // cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_GROUPS , groupIds );
  251                             /*
  252                              * Sam ple for cr eating use r ID and p assword
  253                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_USERID , "userId" );
  254                              * cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_PASSWO RD,
  255                              * "pa ssword");
  256                              */
  257                             // cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_USERID , username );
  258                             // cus tomPropert ies.put(At tributeNam eConstants .WSCREDENT IAL_PASSWO RD,
  259                             // pas swordChar) ;
  260  
  261                             // _su bject.getP rivateCred entials(). add("usern ame = " +  username);
  262                             // _su bject.getP rivateCred entials(). add("passw ord = " +  "us3rpa88" );
  263                             // if  (realm !=  null) {
  264                             // _su bject.getP rivateCred entials(). add("realm  = " + rea lm);
  265                             // }
  266                             // _su bject.getP rivateCred entials(). add("authM echOid = "  +
  267                             // aut hMechOid.t oString()) ;
  268                             UserRe gistry reg  = com.ibm .wsspi.sec urity.regi stry.Regis tryHelper. getUserReg istry(null );
  269  
  270                             // Ret rieves the  registry  uniqueID b ased on th e userName  that is s pecified
  271                             // in  the NameCa llback.
  272                             if (re g != null  && success ) {
  273                                      String u niqueid =  reg.getUni queUserId( username);
  274                                      logger.i nfo("regis try unique  id " + un iqueid);
  275                                      customPr operties.p ut(Attribu teNameCons tants.WSCR EDENTIAL_U NIQUEID, u niqueid);
  276  
  277                                      String r egrealm =  reg.getRea lm();
  278                                      logger.i nfo("regis try realm   " + regre alm);
  279                                      customPr operties.p ut(Attribu teNameCons tants.WSCR EDENTIAL_R EALM, regr ealm);
  280  
  281                                      // Strip  the realm  name and  get real u niqueID
  282                                      List<Str ing> group s = reg.ge tGroupsFor User(usern ame);
  283                                      if (grou ps != null ) {
  284                                               logger.inf o("registr y group si ze  " + gr oups.size( ));
  285                                               Iterator g it = group s.iterator ();
  286                                               while (git .hasNext() ) {
  287                                                       lo gger.info( (String) g it.next()) ;
  288                                               }
  289                                               customProp erties.put (Attribute NameConsta nts.WSCRED ENTIAL_GRO UPS, group s);
  290                                      }
  291                                      // Retri eves the s ecurity na me from th e user reg istry base d on the u niqueID.
  292                                      String s ecurityNam e = reg.ge tUserSecur ityName(un iqueid);
  293                                      logger.i nfo("regis try securi tyName = "  + securit yName);
  294                                      customPr operties.p ut(Attribu teNameCons tants.WSCR EDENTIAL_S ECURITYNAM E, securit yName);
  295  
  296                                      // custo mPropertie s.put(Attr ibuteNameC onstants.W SCREDENTIA L_PRIMARYG ROUPID,
  297                                      // "FRTT eam");
  298  
  299                                      // WSCre dential ws Cred = reg .createCre dential(us ername);
  300                                      // if (w sCred != n ull)
  301                                      // {
  302                                      // logge r.info("re gistry WSC redential  group size  =
  303                                      // "+wsC red.getGro upIds().si ze());
  304                                      // }
  305                             }
  306                             // myS haredState .put(mapKe y, customP roperties) ;
  307                             
  308                             
  309                             
  310                             myShar edState.pu t(Attribut eNameConst ants.WSCRE DENTIAL_PR OPERTIES_K EY, custom Properties );
  311                             
  312                    } ca tch (Entry NotFoundEx ception e)  {
  313                             // TOD O Auto-gen erated cat ch block
  314                             e.prin tStackTrac e();
  315                             logger .exception (this, met hodName, e );
  316                    } ca tch (Custo mRegistryE xception e ) {
  317                             // TOD O Auto-gen erated cat ch block
  318                             e.prin tStackTrac e();
  319                             logger .exception (this, met hodName, e );
  320                    } ca tch (Remot eException  e) {
  321                             // TOD O Auto-gen erated cat ch block
  322                             e.prin tStackTrac e();
  323                             logger .exception (this, met hodName, e );
  324                    } ca tch (WSSec urityExcep tion e) {
  325                             // TOD O Auto-gen erated cat ch block
  326                             logger .exception (this, met hodName, e );
  327                    }
  328                    // c atch (Cred entialDest royedExcep tion e) {
  329                    // / / TODO Aut o-generate d catch bl ock
  330                    // l ogger.exce ption(this , methodNa me, e);
  331                    // }
  332                    logg er.info("l ogin succe ss: "+succ ess);
  333                    logg er.traceEx it(this, m ethodName) ;
  334                    retu rn success ;
  335           }
  336  
  337           pu blic boole an commit( ) throws L oginExcept ion {
  338                    fina l String m ethodName  = "commit" ;
  339                    logg er.traceEn try(this,  methodName );
  340                    bool ean succee ded = true ;
  341                    // t ry {
  342                    // A ccessContr oller.doPr ivileged(n ew Privile gedExcepti onAction<O bject>() {
  343                    // p ublic Obje ct run() t hrows Exce ption {
  344                    // / / add a Pr incipal (a uthenticat ed identit y)
  345                    // / / to the S ubject
  346                    //
  347                    // / / assume t he user we  authentic ated is th e SamplePr incipal
  348                    iamP rincipal =  new CCRSI AMPrincipa l(username );
  349                    if ( !_subject. getPrincip als().cont ains(iamPr incipal))  {
  350                             _subje ct.getPrin cipals().a dd(iamPrin cipal);
  351                             logger .info("IAM Principal  added to s ubject "+i amPrincipa l.getName( ));
  352                    }
  353                    //
  354                    //
  355                    // / / in any c ase, clean  out state
  356                     //// usern ame =  AI    ;
  357                    ////  for (int  i = 0; i <  password. length; i+ +)
  358                    ////  password[ i] = ' ';
  359                     //// passw ord =  AI    ;
  360                    ////
  361                    ////  commitSuc ceeded = t rue;
  362                    ////  return tr ue;
  363                    ////  _subject. getPrivate Credential s().add(cu stomPrivat eCredentia l);
  364                    // r eturn null ;
  365                    // }
  366                    //
  367                    // } );
  368                    // }  catch (Pr ivilegedAc tionExcept ion e) {
  369                    // t hrow new L oginExcept ion(e.getL ocalizedMe ssage());
  370                    // }
  371                    retu rn succeed ed;
  372           }
  373  
  374           pu blic boole an abort()  {
  375                    fina l String m ethodName  = "abort";
  376                    logg er.traceEn try(this,  methodName );
  377                    retu rn true;
  378           }
  379  
  380           pu blic boole an logout( ) {
  381                    fina l String m ethodName  = "logout" ;
  382                    logg er.traceEn try(this,  methodName );
  383                    retu rn true;
  384           }
  385  
  386   }