org.shredzone.acme4j.util.KeyPairUtils Java Examples

The following examples show how to use org.shredzone.acme4j.util.KeyPairUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CertGenerator.java    From spring-boot-starter-acme with Apache License 2.0 5 votes vote down vote up
/**
 * Loads a key pair from specified file. If the file does not exist,
 * a new key pair is generated and saved.
 *
 * @return {@link KeyPair}.
 */
private KeyPair loadOrCreateKeyPair(File file) throws IOException {
  if (file.exists()) {
    try (FileReader fr = new FileReader(file)) {
      return KeyPairUtils.readKeyPair(fr);
    }
  } else {
    KeyPair domainKeyPair = KeyPairUtils.createKeyPair(KEY_SIZE);
    try (FileWriter fw = new FileWriter(file)) {
      KeyPairUtils.writeKeyPair(domainKeyPair, fw);
    }
    return domainKeyPair;
  }
}
 
Example #2
Source File: AcmeClient.java    From r2cloud with Apache License 2.0 5 votes vote down vote up
private KeyPair loadOrCreateKeyPair(File file) throws IOException {
	if (file.exists()) {
		messages.add("loading keypair", LOG);
		try (FileReader fr = new FileReader(file)) {
			return KeyPairUtils.readKeyPair(fr);
		}
	} else {
		return createKeyPair(file);
	}
}
 
Example #3
Source File: AcmeClient.java    From r2cloud with Apache License 2.0 5 votes vote down vote up
private KeyPair createKeyPair(File file) throws IOException {
	messages.add("creating keypair", LOG);
	KeyPair keyPair = KeyPairUtils.createKeyPair(2048);
	try (FileWriter fw = new FileWriter(file)) {
		KeyPairUtils.writeKeyPair(keyPair, fw);
	}
	return keyPair;
}
 
Example #4
Source File: AcmeClient.java    From blynk-server with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads a key pair from specified file. If the file does not exist,
 * a new key pair is generated and saved.
 *
 * @return {@link KeyPair}.
 */
private KeyPair loadOrCreateKeyPair(File file) throws IOException {
    if (file.exists()) {
        try (FileReader fr = new FileReader(file)) {
            return KeyPairUtils.readKeyPair(fr);
        }
    } else {
        KeyPair domainKeyPair = KeyPairUtils.createKeyPair(KEY_SIZE);
        try (FileWriter fw = new FileWriter(file)) {
            KeyPairUtils.writeKeyPair(domainKeyPair, fw);
        }
        return domainKeyPair;
    }
}
 
Example #5
Source File: IOManager.java    From acme_client with MIT License 4 votes vote down vote up
public static KeyPair readKeyPairFromPrivateKey(String filePath) throws IOException {
    try (FileReader fr = new FileReader(filePath)) {
        return KeyPairUtils.readKeyPair(fr);
    }
}
 
Example #6
Source File: IOManager.java    From acme_client with MIT License 4 votes vote down vote up
public static KeyPair readKeyPairFromPrivateKey(File file) throws IOException {
    try (FileReader fr = new FileReader(file)) {
        return KeyPairUtils.readKeyPair(fr);
    }
}