-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command pki-server kra-range-generator-update
- Loading branch information
Showing
5 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class CARangeGeneratorCLI extends CLI{ | ||
public class CARangeGeneratorCLI extends CLI { | ||
|
||
public CARangeGeneratorCLI(CLI parent) { | ||
super("generator", "CA range generator commands", parent); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
base/kra/src/main/java/org/dogtagpki/server/kra/cli/KRARangeGeneratorCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.kra.cli; | ||
|
||
import org.dogtagpki.cli.CLI; | ||
/** | ||
* @author Marco Fargetta {@literal <[email protected]>} | ||
*/ | ||
public class KRARangeGeneratorCLI extends CLI { | ||
public KRARangeGeneratorCLI(CLI parent) { | ||
super("generator", "kra range generator commands", parent); | ||
|
||
addModule(new kraRangeGeneratorUpdateCLI(this)); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
base/kra/src/main/java/org/dogtagpki/server/kra/cli/kraRangeGeneratorUpdateCLI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Copyright Red Hat, Inc. | ||
// | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// | ||
package org.dogtagpki.server.kra.cli; | ||
|
||
import com.netscape.cmscore.apps.DatabaseConfig; | ||
import com.netscape.cmscore.dbs.KeyRepository; | ||
import com.netscape.cmscore.dbs.Repository; | ||
import com.netscape.cmscore.ldapconn.LdapAuthInfo; | ||
import com.netscape.cmscore.ldapconn.LdapConnInfo; | ||
import com.netscape.cmscore.ldapconn.PKISocketFactory; | ||
import org.dogtagpki.cli.CLI; | ||
import org.dogtagpki.server.cli.SubsystemRangeGeneratorUpdateCLI; | ||
|
||
/** | ||
* | ||
* @author mfargetta | ||
*/ | ||
public class kraRangeGeneratorUpdateCLI extends SubsystemRangeGeneratorUpdateCLI { | ||
|
||
public kraRangeGeneratorUpdateCLI(CLI parent) { | ||
super(parent); | ||
} | ||
|
||
@Override | ||
protected void updateSerialNumberRangeGenerator(PKISocketFactory socketFactory, LdapConnInfo connInfo, | ||
LdapAuthInfo authInfo, DatabaseConfig dbConfig, String baseDN, Repository.IDGenerator newGenerator, String hostName, String securePort) throws Exception { | ||
String value = dbConfig.getString( | ||
KeyRepository.PROP_KEY_ID_GENERATOR, | ||
KeyRepository.DEFAULT_KEY_ID_GENERATOR); | ||
idGenerator = Repository.IDGenerator.fromString(value); | ||
|
||
if (newGenerator == Repository.IDGenerator.RANDOM && idGenerator != Repository.IDGenerator.RANDOM) { | ||
dbConfig.put(KeyRepository.PROP_KEY_ID_GENERATOR, newGenerator.toString()); | ||
dbConfig.put(KeyRepository.PROP_KEY_ID_LENGTH, "128"); | ||
} | ||
if (newGenerator == Repository.IDGenerator.LEGACY_2 && idGenerator == Repository.IDGenerator.LEGACY) { | ||
dbConfig.put(KeyRepository.PROP_KEY_ID_GENERATOR, newGenerator.toString()); | ||
} | ||
|
||
super.updateSerialNumberRangeGenerator(socketFactory, connInfo, authInfo, dbConfig, baseDN, newGenerator, hostName, securePort); | ||
} | ||
} |