@Test void create_test(){ assertAll( () -> assertThat(SignatureAlgorithm.create("SHA256withECDSA")).isEqualTo(SignatureAlgorithm.ES256), () -> assertThat(SignatureAlgorithm.create("SHA384withECDSA")).isEqualTo(SignatureAlgorithm.ES384), () -> assertThat(SignatureAlgorithm.create("SHA512withECDSA")).isEqualTo(SignatureAlgorithm.ES512), () -> assertThat(SignatureAlgorithm.create("SHA1withRSA")).isEqualTo(SignatureAlgorithm.RS1), () -> assertThat(SignatureAlgorithm.create("SHA256withRSA")).isEqualTo(SignatureAlgorithm.RS256), () -> assertThat(SignatureAlgorithm.create("SHA384withRSA")).isEqualTo(SignatureAlgorithm.RS384), () -> assertThat(SignatureAlgorithm.create("SHA512withRSA")).isEqualTo(SignatureAlgorithm.RS512) ); }
@JsonCreator public static SignatureAlgorithm create(String jcaName){ switch (jcaName){ case "SHA256withECDSA": return ES256; case "SHA384withECDSA": return ES384; case "SHA512withECDSA": return ES512; case "SHA1withRSA": return RS1; case "SHA256withRSA": return RS256; case "SHA384withRSA": return RS384; case "SHA512withRSA": return RS512; default: throw new IllegalArgumentException(String.format("jcaName %s is not supported.", jcaName)); } }
SignatureAlgorithm { @JsonCreator public static SignatureAlgorithm create(String jcaName){ switch (jcaName){ case "SHA256withECDSA": return ES256; case "SHA384withECDSA": return ES384; case "SHA512withECDSA": return ES512; case "SHA1withRSA": return RS1; case "SHA256withRSA": return RS256; case "SHA384withRSA": return RS384; case "SHA512withRSA": return RS512; default: throw new IllegalArgumentException(String.format("jcaName %s is not supported.", jcaName)); } } }
SignatureAlgorithm { @JsonCreator public static SignatureAlgorithm create(String jcaName){ switch (jcaName){ case "SHA256withECDSA": return ES256; case "SHA384withECDSA": return ES384; case "SHA512withECDSA": return ES512; case "SHA1withRSA": return RS1; case "SHA256withRSA": return RS256; case "SHA384withRSA": return RS384; case "SHA512withRSA": return RS512; default: throw new IllegalArgumentException(String.format("jcaName %s is not supported.", jcaName)); } } private  SignatureAlgorithm(String jcaName, MessageDigestAlgorithm messageDigestAlgorithm); }
SignatureAlgorithm { @JsonCreator public static SignatureAlgorithm create(String jcaName){ switch (jcaName){ case "SHA256withECDSA": return ES256; case "SHA384withECDSA": return ES384; case "SHA512withECDSA": return ES512; case "SHA1withRSA": return RS1; case "SHA256withRSA": return RS256; case "SHA384withRSA": return RS384; case "SHA512withRSA": return RS512; default: throw new IllegalArgumentException(String.format("jcaName %s is not supported.", jcaName)); } } private  SignatureAlgorithm(String jcaName, MessageDigestAlgorithm messageDigestAlgorithm); @JsonCreator static SignatureAlgorithm create(String jcaName); static SignatureAlgorithm create(String jcaName, String messageDigestJcaName); @JsonValue String getJcaName(); MessageDigestAlgorithm getMessageDigestAlgorithm(); @Override boolean equals(Object o); @Override int hashCode(); }
SignatureAlgorithm { @JsonCreator public static SignatureAlgorithm create(String jcaName){ switch (jcaName){ case "SHA256withECDSA": return ES256; case "SHA384withECDSA": return ES384; case "SHA512withECDSA": return ES512; case "SHA1withRSA": return RS1; case "SHA256withRSA": return RS256; case "SHA384withRSA": return RS384; case "SHA512withRSA": return RS512; default: throw new IllegalArgumentException(String.format("jcaName %s is not supported.", jcaName)); } } private  SignatureAlgorithm(String jcaName, MessageDigestAlgorithm messageDigestAlgorithm); @JsonCreator static SignatureAlgorithm create(String jcaName); static SignatureAlgorithm create(String jcaName, String messageDigestJcaName); @JsonValue String getJcaName(); MessageDigestAlgorithm getMessageDigestAlgorithm(); @Override boolean equals(Object o); @Override int hashCode(); static final SignatureAlgorithm ES256; static final SignatureAlgorithm ES384; static final SignatureAlgorithm ES512; static final SignatureAlgorithm RS1; static final SignatureAlgorithm RS256; static final SignatureAlgorithm RS384; static final SignatureAlgorithm RS512; }