@ Override public boolean get ( URIish uri , CredentialItem ... items ) throws UnsupportedCredentialItem { String codeCommitPassword ; String awsAccessKey ; String awsSecretKey ; try { AWSCredentials awsCredentials = retrieveAwsCredentials ( ) ; StringBuilder awsKey = new StringBuilder ( ) ; awsKey . append ( awsCredentials . getAWSAccessKeyId ( ) ) ; awsSecretKey = awsCredentials . getAWSSecretKey ( ) ; if ( awsCredentials instanceof AWSSessionCredentials ) { AWSSessionCredentials sessionCreds = ( AWSSessionCredentials ) awsCredentials ; if ( sessionCreds . getSessionToken ( ) != null ) { awsKey . append ( ' ' ) . append ( sessionCreds . getSessionToken ( ) ) ; } } awsAccessKey = awsKey . toString ( ) ; } catch ( Throwable t ) { this . logger . warn ( "Unable to retrieve AWS Credentials" , t ) ; return false ; } try { codeCommitPassword = calculateCodeCommitPassword ( uri , awsSecretKey ) ; } catch ( Throwable t ) { this . logger . warn ( "Error calculating the AWS CodeCommit password" , t ) ; return false ; } for ( CredentialItem i : items ) { if ( i instanceof CredentialItem . Username ) { ( ( CredentialItem . Username ) i ) . setValue ( awsAccessKey ) ; this . logger . trace ( "Returning username " + awsAccessKey ) ; continue ; } if ( i instanceof CredentialItem . Password ) { ( ( CredentialItem . Password ) i ) . setValue ( codeCommitPassword . toCharArray ( ) ) ; this . logger . trace ( "Returning password " + codeCommitPassword ) ; continue ; } if ( i instanceof CredentialItem . StringType && i . getPromptText ( ) . equals ( "Password: " ) ) { //$NON-NLS-1$ ( ( CredentialItem . StringType ) i ) . setValue ( codeCommitPassword ) ; this . logger . trace ( "Returning password string " + codeCommitPassword ) ; continue ; } throw new UnsupportedCredentialItem ( uri , i . getClass ( ) . getName ( ) + ":" + i . getPromptText ( ) ) ; //$NON-NLS-1$ } return true ; }
Get the username and password to use for the given uri .