}
if (serviceIterator == null) {
return null;
}
while (serviceIterator.hasNext()) {
Service s = serviceIterator.next();
try {
Object inst = s.newInstance(null);
// ignore non-spis
if (inst instanceof KeyPairGeneratorSpi == false) {
continue;
}
if (inst instanceof KeyPairGenerator) {
continue;
}
KeyPairGeneratorSpi spi = (KeyPairGeneratorSpi)inst;
if (reinit) {
if (initType == I_SIZE) {
spi.initialize(initKeySize, initRandom);
} else if (initType == I_PARAMS) {
spi.initialize(initParams, initRandom);
} else if (initType != I_NONE) {
throw new AssertionError
("KeyPairGenerator initType: " + initType);
}
}
provider = s.getProvider();
this.spi = spi;
return spi;
} catch (Exception e) {
// ignore
}