@ Override public boolean execute ( ProtocolDataUnit pdu ) throws IOException , InterruptedException , InternetSCSIException , DigestException , SettingsException { // begin login negotiation final ConnectionSettingsNegotiator negotiator = connection . getConnectionSettingsNegotiator ( ) ; while ( ! negotiator . beginNegotiation ( ) ) { // do nothing, just wait for permission to begin, method is blocking } boolean loginSuccessful = true ; // will determine if settings are // committed try { // if possible, enter LOPN Stage BasicHeaderSegment bhs = pdu . getBasicHeaderSegment ( ) ; LoginRequestParser parser = ( LoginRequestParser ) bhs . getParser ( ) ; LoginStage nextStageNumber ; // will store return value from the last // login stage // Security Negotiation Stage (optional) if ( parser . getCurrentStageNumber ( ) == LoginStage . SECURITY_NEGOTIATION ) { // complete SNS stage = new SecurityNegotiationStage ( this ) ; stage . execute ( pdu ) ; nextStageNumber = stage . getNextStageNumber ( ) ; if ( nextStageNumber != null ) authenticated = true ; else { loginSuccessful = false ; return false ; } if ( nextStageNumber == LoginStage . LOGIN_OPERATIONAL_NEGOTIATION ) { // receive first PDU from LOPNS pdu = connection . receivePdu ( ) ; bhs = pdu . getBasicHeaderSegment ( ) ; parser = ( LoginRequestParser ) bhs . getParser ( ) ; } else if ( nextStageNumber == LoginStage . FULL_FEATURE_PHASE ) { // we are done here return true ; } else { // should be unreachable, since SNS may not return NSG==SNS loginSuccessful = false ; return false ; } } // Login Operational Parameter Negotiation Stage (also optional, but // either SNS or LOPNS must be passed before proceeding to FFP) if ( parser != null && authenticated && parser . getCurrentStageNumber ( ) == LoginStage . LOGIN_OPERATIONAL_NEGOTIATION ) { stage = new LoginOperationalParameterNegotiationStage ( this ) ; stage . execute ( pdu ) ; nextStageNumber = stage . getNextStageNumber ( ) ; if ( nextStageNumber == LoginStage . FULL_FEATURE_PHASE ) return true ; } // else loginSuccessful = false ; return false ; } catch ( DigestException e ) { loginSuccessful = false ; throw e ; } catch ( IOException e ) { loginSuccessful = false ; throw e ; } catch ( InterruptedException e ) { loginSuccessful = false ; throw e ; } catch ( InternetSCSIException e ) { loginSuccessful = false ; throw e ; } catch ( SettingsException e ) { loginSuccessful = false ; throw e ; } finally { // commit or roll back changes and release exclusive negotiator lock negotiator . finishNegotiation ( loginSuccessful ) ; } }
Starts the login phase .