/**
* Parses the credential information from a form submission.
*/
public static UserProvidedCredential fromForm(StaplerRequest req, MultipartFormDataParser parser) throws IOException {
CrumbIssuer crumbIssuer = Hudson.getInstance().getCrumbIssuer();
if (crumbIssuer!=null && !crumbIssuer.validateCrumb(req, parser))
throw HttpResponses.error(SC_FORBIDDEN,new IOException("No crumb found"));
String kind = parser.get("kind");
int idx = Arrays.asList("","password","publickey","certificate").indexOf(kind);