Skip to content

Commit

Permalink
[JENKINS-41946] Fix "IllegalArgumentException: Unable to convert to c…
Browse files Browse the repository at this point in the history
…lass com.cloudbees.plugins.credentials.SecretBytes"
  • Loading branch information
cyrille-leclerc committed Feb 11, 2017
1 parent 72aef0d commit 03b497e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/com/cloudbees/plugins/credentials/SecretBytes.java
Expand Up @@ -45,6 +45,7 @@
import javax.crypto.Cipher;
import jcifs.util.Base64;
import jenkins.security.ConfidentialStore;
import org.apache.commons.lang.IllegalClassException;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.Stapler;
Expand Down Expand Up @@ -351,7 +352,20 @@ public Object unmarshal(HierarchicalStreamReader reader, final UnmarshallingCont
}
}

public static class StaplerConverterImpl implements org.apache.commons.beanutils.Converter {
public SecretBytes convert(Class type, Object value) {
if (value==null)
return null;
if (value instanceof String) {
return SecretBytes.fromString((String) value);
}
throw new IllegalClassException(SecretBytes.class, value.getClass());
}
}

/*
* TODO why do we need this static registration if we have StaplerConverterImpl?
*
* Register a converter for Stapler form binding.
*/
static {
Expand Down

0 comments on commit 03b497e

Please sign in to comment.