-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
309 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
src/main/java/org/jenkinsci/plugins/jvctb/JvctbLogger.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/org/jenkinsci/plugins/jvctb/config/CredentialsHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.jenkinsci.plugins.jvctb.config; | ||
|
||
import static com.cloudbees.plugins.credentials.CredentialsMatchers.allOf; | ||
import static com.cloudbees.plugins.credentials.CredentialsMatchers.firstOrNull; | ||
import static com.cloudbees.plugins.credentials.CredentialsMatchers.withId; | ||
import static com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials; | ||
import static com.google.common.base.Optional.absent; | ||
import static com.google.common.base.Optional.fromNullable; | ||
import static com.google.common.base.Strings.isNullOrEmpty; | ||
import static hudson.security.ACL.SYSTEM; | ||
import hudson.model.ItemGroup; | ||
import hudson.util.ListBoxModel; | ||
|
||
import java.util.List; | ||
|
||
import org.acegisecurity.Authentication; | ||
|
||
import com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel; | ||
import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; | ||
import com.cloudbees.plugins.credentials.common.StandardUsernameListBoxModel; | ||
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; | ||
import com.cloudbees.plugins.credentials.domains.DomainRequirement; | ||
import com.google.common.base.Optional; | ||
|
||
public class CredentialsHelper { | ||
public static ListBoxModel doFillUsernamePasswordCredentialsIdItems() { | ||
List<StandardUsernamePasswordCredentials> credentials = getAllCredentials(); | ||
AbstractIdCredentialsListBoxModel<StandardUsernameListBoxModel, StandardUsernameCredentials> listBoxModel = new StandardUsernameListBoxModel() | ||
.includeEmptyValue(); | ||
for (StandardUsernamePasswordCredentials credential : credentials) { | ||
listBoxModel.with(credential); | ||
} | ||
return listBoxModel; | ||
} | ||
|
||
public static Optional<StandardUsernamePasswordCredentials> findCredentials(String usernamePasswordCredentialsId) { | ||
if (isNullOrEmpty(usernamePasswordCredentialsId)) { | ||
return absent(); | ||
} | ||
|
||
return fromNullable(firstOrNull(getAllCredentials(), allOf(withId(usernamePasswordCredentialsId)))); | ||
} | ||
|
||
public static List<StandardUsernamePasswordCredentials> getAllCredentials() { | ||
Class<StandardUsernamePasswordCredentials> type = StandardUsernamePasswordCredentials.class; | ||
ItemGroup<?> itemGroup = null; | ||
Authentication authentication = SYSTEM; | ||
DomainRequirement domainRequirement = null; | ||
|
||
return lookupCredentials(type, itemGroup, authentication, domainRequirement); | ||
} | ||
|
||
} |
Oops, something went wrong.