jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
changeset 4337 2a6d13ebbbed
parent 4336 4c792c19266e
child 5506 202f599c92aa
equal deleted inserted replaced
4336:4c792c19266e 4337:2a6d13ebbbed
   315 
   315 
   316                 // get the token for first mechanism
   316                 // get the token for first mechanism
   317                 mechToken = GSS_initSecContext(null);
   317                 mechToken = GSS_initSecContext(null);
   318 
   318 
   319                 errorCode = GSSException.DEFECTIVE_TOKEN;
   319                 errorCode = GSSException.DEFECTIVE_TOKEN;
   320                 byte[] micToken = null;
       
   321                 if (!GSSUtil.useMSInterop()) {
       
   322                     // calculate MIC only in normal mode
       
   323                     micToken = generateMechListMIC(DER_mechTypes);
       
   324                 }
       
   325                 // generate SPNEGO token
   320                 // generate SPNEGO token
   326                 initToken = new NegTokenInit(DER_mechTypes, getContextFlags(),
   321                 initToken = new NegTokenInit(DER_mechTypes, getContextFlags(),
   327                                         mechToken, micToken);
   322                                         mechToken, null);
   328                 if (DEBUG) {
   323                 if (DEBUG) {
   329                     System.out.println("SpNegoContext.initSecContext: " +
   324                     System.out.println("SpNegoContext.initSecContext: " +
   330                                 "sending token of type = " +
   325                                 "sending token of type = " +
   331                                 SpNegoToken.getTokenName(initToken.getType()));
   326                                 SpNegoToken.getTokenName(initToken.getType()));
   332                 }
   327                 }
   581                                 "mechanism wanted = " + mech_wanted);
   576                                 "mechanism wanted = " + mech_wanted);
   582                     System.out.println("SpNegoContext.acceptSecContext: " +
   577                     System.out.println("SpNegoContext.acceptSecContext: " +
   583                                 "negotiated result = " + negoResult);
   578                                 "negotiated result = " + negoResult);
   584                 }
   579                 }
   585 
   580 
   586                 // calculate MIC only in normal mode
       
   587                 byte[] micToken = null;
       
   588                 if (!GSSUtil.useMSInterop() && valid) {
       
   589                     micToken = generateMechListMIC(DER_mechTypes);
       
   590                 }
       
   591 
       
   592                 // generate SPNEGO token
   581                 // generate SPNEGO token
   593                 NegTokenTarg targToken = new NegTokenTarg(negoResult.ordinal(),
   582                 NegTokenTarg targToken = new NegTokenTarg(negoResult.ordinal(),
   594                                 mech_wanted, accept_token, micToken);
   583                                 mech_wanted, accept_token, null);
   595                 if (DEBUG) {
   584                 if (DEBUG) {
   596                     System.out.println("SpNegoContext.acceptSecContext: " +
   585                     System.out.println("SpNegoContext.acceptSecContext: " +
   597                                 "sending token of type = " +
   586                                 "sending token of type = " +
   598                                 SpNegoToken.getTokenName(targToken.getType()));
   587                                 SpNegoToken.getTokenName(targToken.getType()));
   599                 }
   588                 }
   733             }
   722             }
   734         }
   723         }
   735     }
   724     }
   736 
   725 
   737     /**
   726     /**
   738      * generate MIC on mechList
   727      * generate MIC on mechList. Not used at the moment.
   739      */
   728      */
   740     private byte[] generateMechListMIC(byte[] mechTypes)
   729     /*private byte[] generateMechListMIC(byte[] mechTypes)
   741         throws GSSException {
   730         throws GSSException {
   742 
   731 
   743         // sanity check the required input
   732         // sanity check the required input
   744         if (mechTypes == null) {
   733         if (mechTypes == null) {
   745             if (DEBUG) {
   734             if (DEBUG) {
   772                 System.out.println("SpNegoContext: no MIC token included" +
   761                 System.out.println("SpNegoContext: no MIC token included" +
   773                         " - getMIC failed : " + e.getMessage());
   762                         " - getMIC failed : " + e.getMessage());
   774             }
   763             }
   775         }
   764         }
   776         return mic;
   765         return mic;
   777     }
   766     }*/
   778 
   767 
   779     /**
   768     /**
   780      * verify MIC on MechList
   769      * verify MIC on MechList
   781      */
   770      */
   782     private boolean verifyMechListMIC(byte[] mechTypes, byte[] token)
   771     private boolean verifyMechListMIC(byte[] mechTypes, byte[] token)