Skip to content

Commit

Permalink
This PR fixes JENKINS-32987, it completes PR #68 (#70)
Browse files Browse the repository at this point in the history
* Update `credentials` to 1.21 to support custom credential ID

* JENKINS-32987 - id + description shouldn't be redefined and it is better to keep but deprecated the previous constructor
  • Loading branch information
aheritier committed Sep 20, 2016
1 parent 2f8f701 commit 3cf6865
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -83,7 +83,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.4</version>
<version>1.21</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down
60 changes: 23 additions & 37 deletions src/main/java/au/com/rayh/DeveloperProfile.java
@@ -1,64 +1,53 @@
package au.com.rayh;

import com.cloudbees.plugins.credentials.BaseCredentials;
import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.CredentialsScope;
import hudson.Extension;
import hudson.util.IOUtils;
import hudson.util.Secret;
import jenkins.security.ConfidentialKey;
import org.apache.commons.fileupload.FileItem;
import org.kohsuke.stapler.DataBoundConstructor;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;
import javax.security.auth.x500.X500Principal;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.naming.InvalidNameException;
import javax.naming.ldap.LdapName;
import javax.naming.ldap.Rdn;

import jenkins.security.ConfidentialKey;

import org.apache.commons.fileupload.FileItem;
import org.kohsuke.stapler.DataBoundConstructor;

import com.cloudbees.plugins.credentials.CredentialsDescriptor;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials;

/**
* Apple developer profile, which consists of any number of PKCS12 of the private key
* and the certificate for code signing, and mobile provisioning profiles.
*
* @author Kohsuke Kawaguchi
*/
public class DeveloperProfile extends BaseCredentials {
public class DeveloperProfile extends BaseStandardCredentials {
/**
* Password of the PKCS12 files inside the profile.
*/
private Secret password;

/**
* Random generated unique ID that identifies this developer profile among others.
*/
private final String id;

private final String description;

@DataBoundConstructor
public DeveloperProfile(String id, String description, Secret password, FileItem image) throws IOException {
super(CredentialsScope.GLOBAL);
if (id==null)
id = UUID.randomUUID().toString();
this.id = id;
this.description = description;
public DeveloperProfile(@CheckForNull CredentialsScope scope, @CheckForNull String id, @CheckForNull String description,
Secret password, FileItem image) throws IOException {
super(scope, id, description);
this.password= password;

if (image!=null) {
Expand All @@ -67,12 +56,9 @@ public DeveloperProfile(String id, String description, Secret password, FileItem
}
}

public String getId() {
return id;
}

public String getDescription() {
return description;
@Deprecated
public DeveloperProfile(String id, String description, Secret password, FileItem image) throws IOException {
this(CredentialsScope.GLOBAL,id,description,password,image);
}

public Secret getPassword() {
Expand All @@ -83,7 +69,7 @@ public Secret getPassword() {
* Retrieves the PKCS12 byte image.
*/
public byte[] getImage() throws IOException {
return new ConfidentialKeyImpl(id).load();
return new ConfidentialKeyImpl(getId()).load();
}

/**
Expand Down

0 comments on commit 3cf6865

Please sign in to comment.