org.hyperledger.fabric.sdk.identity.IdentityFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-sdk-java Show documentation
Show all versions of fabric-sdk-java Show documentation
Java SDK for Hyperledger Fabric. Deprecated as of Fabric v2.5, replaced by org.hyperledger.fabric:fabric-gateway.
package org.hyperledger.fabric.sdk.identity;
import org.hyperledger.fabric.sdk.Enrollment;
import org.hyperledger.fabric.sdk.User;
import org.hyperledger.fabric.sdk.security.CryptoSuite;
public class IdentityFactory {
private IdentityFactory() {
// private constructor for utility class
}
public static SigningIdentity getSigningIdentity(CryptoSuite cryptoSuite, User user) {
Enrollment enrollment = user.getEnrollment();
try {
if (enrollment instanceof IdemixEnrollment) { // Need Idemix signer for this.
return new IdemixSigningIdentity((IdemixEnrollment) enrollment);
} else { // for now all others are x509
return new X509SigningIdentity(cryptoSuite, user);
}
} catch (Exception e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
}