use of de.carne.jfx.util.DefaultSet in project certmgr by hdecarne.
the class CRLUpdatePeriod method getDefaultSet.
/**
* Get the standard CRL Update Periods.
*
* @param defaultHint The default to return (may be {@code null}). If this period is contained in the default set,
* it is also set as the default.
* @return The standard CRL Update Periods.
*/
public static DefaultSet<CRLUpdatePeriod> getDefaultSet(@Nullable Days defaultHint) {
DefaultSet<Days> defaultPeriods = SecurityDefaults.getCRLUpdatedPeriods();
DefaultSet<CRLUpdatePeriod> crlUpdatePeriods = new DefaultSet<>();
if (defaultHint != null) {
crlUpdatePeriods.addDefault(new CRLUpdatePeriod(defaultHint));
} else {
crlUpdatePeriods.addDefault(new CRLUpdatePeriod(Check.notNull(defaultPeriods.getDefault())));
}
for (Days period : defaultPeriods) {
crlUpdatePeriods.add(new CRLUpdatePeriod(period));
}
return crlUpdatePeriods;
}
use of de.carne.jfx.util.DefaultSet in project certmgr by hdecarne.
the class CRTValidityPeriod method getDefaultSet.
/**
* Get the standard CRT Validity Periods.
*
* @param defaultHint The default to return (may be {@code null}). If this period is contained in the default set,
* it is also set as the default.
* @return The standard CRT Validity Periods.
*/
public static DefaultSet<CRTValidityPeriod> getDefaultSet(@Nullable Days defaultHint) {
DefaultSet<Days> defaultPeriods = SecurityDefaults.getCRTValidityPeriods();
DefaultSet<CRTValidityPeriod> crlUpdatePeriods = new DefaultSet<>();
if (defaultHint != null) {
crlUpdatePeriods.addDefault(new CRTValidityPeriod(defaultHint));
} else {
crlUpdatePeriods.addDefault(new CRTValidityPeriod(Check.notNull(defaultPeriods.getDefault())));
}
for (Days period : defaultPeriods) {
crlUpdatePeriods.add(new CRTValidityPeriod(period));
}
return crlUpdatePeriods;
}
use of de.carne.jfx.util.DefaultSet in project certmgr by hdecarne.
the class KeyPairAlgorithm method getDefaultSet.
/**
* Get the available key pair algorithms.
*
* @param defaultHint The default to return (may be {@code null}). If this algorithm is contained in the default
* set, it is also set as the default.
* @param expertMode Whether only standard algorithms are considered ({@code false}) or all algorithms available on
* the current platform ({@code true}).
* @return The available key pair algorithms
*/
public static DefaultSet<KeyPairAlgorithm> getDefaultSet(@Nullable String defaultHint, boolean expertMode) {
DefaultSet<KeyPairAlgorithm> keyPairAlgorithms = new DefaultSet<>();
DefaultSet<String> defaultNames = SecurityDefaults.getKeyAlgorithmNames();
@Nullable String defaultName = (defaultHint != null && defaultNames.contains(defaultHint) ? defaultHint : defaultNames.getDefault());
for (Provider provider : SecurityDefaults.getProviders(expertMode)) {
for (Provider.Service service : provider.getServices()) {
if (!SERVICE_TYPE_KEY_PAIR_GENERATOR.equals(service.getType())) {
continue;
}
String algorithm = service.getAlgorithm();
if (!expertMode && !defaultNames.contains(algorithm)) {
continue;
}
KeyPairAlgorithm keyPairAlgorithm = (expertMode ? new ExpertKeyPairAlgorithm(service) : new StandardKeyPairAlgorithm(service));
if (algorithm.equals(defaultName)) {
keyPairAlgorithms.addDefault(keyPairAlgorithm);
} else {
keyPairAlgorithms.add(keyPairAlgorithm);
}
}
}
return keyPairAlgorithms;
}
use of de.carne.jfx.util.DefaultSet in project certmgr by hdecarne.
the class PlatformKeyStore method getDefaultSet.
/**
* Get the available platform key stores.
*
* @return The available platform key stores.
*/
public static DefaultSet<PlatformKeyStore> getDefaultSet() {
DefaultSet<PlatformKeyStore> platformKeyStores = new DefaultSet<>();
DefaultSet<String> defaultNames = SecurityDefaults.getPlatformKeyStoreNames();
String defaultName = defaultNames.getDefault();
for (Provider provider : Security.getProviders()) {
for (Provider.Service service : provider.getServices()) {
if (!SERVICE_TYPE_KEY_STORE.equals(service.getType())) {
continue;
}
String algorithm = service.getAlgorithm();
if (!defaultNames.contains(algorithm)) {
continue;
}
PlatformKeyStore platformKeyStore = new PlatformKeyStore(service);
if (algorithm.equals(defaultName)) {
platformKeyStores.addDefault(platformKeyStore);
} else {
platformKeyStores.add(platformKeyStore);
}
}
}
return platformKeyStores;
}
use of de.carne.jfx.util.DefaultSet in project certmgr by hdecarne.
the class LocalCertGenerator method getIssuers.
@Override
public DefaultSet<Issuer> getIssuers(UserCertStore store, @Nullable UserCertStoreEntry defaultHint) {
DefaultSet<Issuer> issuers = new DefaultSet<>();
issuers.addDefault(this.selfSignedIssuer);
if (store != null) {
for (UserCertStoreEntry storeEntry : store.getEntries()) {
if (storeEntry.canIssue()) {
if (storeEntry.equals(defaultHint)) {
issuers.addDefault(new LocalIssuer(storeEntry));
} else {
issuers.add(new LocalIssuer(storeEntry));
}
}
}
}
return issuers;
}
Aggregations