Skip to content

Commit

Permalink
Minor changes around constant access and improving setting of token a…
Browse files Browse the repository at this point in the history
…t runtime
  • Loading branch information
Nathan Dines committed Feb 24, 2019
1 parent 1828b45 commit a3167db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public String getIamMfaSerialNumber() {

@NonNull
public Integer getStsTokenDuration() {
return stsTokenDuration == null ? DescriptorImpl.defaultStsTokenDuration : stsTokenDuration;
return stsTokenDuration == null ? STS_CREDENTIALS_DURATION_SECONDS : stsTokenDuration;
}

@DataBoundSetter
public void setStsTokenDuration(@NonNull Integer stsTokenDuration) {
this.stsTokenDuration = stsTokenDuration.equals(DescriptorImpl.defaultStsTokenDuration) ? null : stsTokenDuration;
public void setStsTokenDuration(Integer stsTokenDuration) {
this.stsTokenDuration = stsTokenDuration == null || stsTokenDuration.intValue() == STS_CREDENTIALS_DURATION_SECONDS ? null : stsTokenDuration;
}

public boolean requiresToken() {
Expand Down Expand Up @@ -210,7 +210,7 @@ public String getDisplayName() {
return Messages.AWSCredentialsImpl_DisplayName();
}

public static final Integer defaultStsTokenDuration = STS_CREDENTIALS_DURATION_SECONDS;
public static final Integer DEFAULT_STS_TOKEN_DURATION = STS_CREDENTIALS_DURATION_SECONDS;

public FormValidation doCheckSecretKey(@QueryParameter("accessKey") final String accessKey,
@QueryParameter("iamRoleArn") final String iamRoleArn,
Expand Down Expand Up @@ -265,7 +265,6 @@ public FormValidation doCheckSecretKey(@QueryParameter("accessKey") final String
LOGGER.log(Level.WARNING, "Unable to assume role [" + iamRoleArn + "] with request [" + assumeRequest + "]", e);
return FormValidation.error(Messages.AWSCredentialsImpl_NotAbleToAssumeRole() + " Check the Jenkins log for more details");
}

}

AmazonEC2 ec2 = new AmazonEC2Client(awsCredentials,clientConfiguration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<f:textbox/>
</f:entry>
<f:entry title="${%STS Token Duration (sec)}" field="stsTokenDuration">
<f:textbox default="${descriptor.defaultStsTokenDuration}"/>
<f:textbox default="${descriptor.DEFAULT_STS_TOKEN_DURATION}"/>
</f:entry>
</f:advanced>
</f:section>
Expand Down

0 comments on commit a3167db

Please sign in to comment.