use of org.jcryptool.crypto.flexiprovider.descriptors.meta.MetaKeyGenerator in project core by jcryptool.
the class FlexiProviderRootElement method initKeyGenerators.
@SuppressWarnings("unchecked")
private static void initKeyGenerators(RegistryType type, Element keyGeneratorParent) {
List<Element> keyGeneratorChildren = new ArrayList<Element>(keyGeneratorParent.getChildren());
Iterator<Element> it = keyGeneratorChildren.iterator();
while (it.hasNext()) {
Element current = it.next();
String className = current.getAttributeValue(AlgorithmsXMLConstants._class);
IMetaKeyGenerator meta = new MetaKeyGenerator(className);
// oid
IMetaOID oid = null;
if (current.getAttributeValue(AlgorithmsXMLConstants._oid) != null) {
oid = new MetaOID(current.getAttributeValue(AlgorithmsXMLConstants._oid));
meta.setOID(oid);
}
// names
List<String> names = new ArrayList<String>();
if (current.getChild(AlgorithmsXMLConstants._Names) != null) {
if (current.getChild(AlgorithmsXMLConstants._Names).getText().contains(",")) {
// $NON-NLS-1$
StringTokenizer tokenizer = // $NON-NLS-1$
new StringTokenizer(current.getChild(AlgorithmsXMLConstants._Names).getText(), ",");
while (tokenizer.hasMoreTokens()) {
names.add(tokenizer.nextToken());
}
} else {
names.add(current.getChild(AlgorithmsXMLConstants._Names).getText());
}
}
meta.setNames(names);
// parameter spec
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec) != null) {
meta.setParameterSpecClassName(current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttributeValue(AlgorithmsXMLConstants._class));
}
// parameter generators
if (current.getChild(AlgorithmsXMLConstants._ParameterGenerator) != null) {
meta.setParameterGeneratorClassName(current.getChild(AlgorithmsXMLConstants._ParameterGenerator).getAttributeValue(AlgorithmsXMLConstants._class));
meta.setParamGenParameterSpecClassName(current.getChild(AlgorithmsXMLConstants._ParameterGenerator).getChild(AlgorithmsXMLConstants._ParameterSpec).getAttributeValue(AlgorithmsXMLConstants._class));
}
// lengths
if (current.getChild(AlgorithmsXMLConstants._KeyStrengths) != null) {
int defaultLength = Integer.valueOf(current.getChild(AlgorithmsXMLConstants._KeyStrengths).getAttributeValue(AlgorithmsXMLConstants._default));
IMetaLength metaLength = new MetaLength(defaultLength);
if (current.getChild(AlgorithmsXMLConstants._KeyStrengths).getText() != null) {
String text = current.getChild(AlgorithmsXMLConstants._KeyStrengths).getText();
if (text.contains(",")) {
// $NON-NLS-1$
List<Integer> lengths = new ArrayList<Integer>(2);
// $NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(text, ",");
while (tokenizer.hasMoreTokens()) {
lengths.add(Integer.valueOf(tokenizer.nextToken()));
}
metaLength.setLengths(lengths);
} else if (text.contains("...")) {
// $NON-NLS-1$
// $NON-NLS-1$
int lowerBound = Integer.valueOf(text.substring(0, text.indexOf("...")));
// $NON-NLS-1$
int upperBound = Integer.valueOf(text.substring(text.indexOf("...") + 3, text.length()));
metaLength.setBounds(lowerBound, upperBound);
}
}
meta.setLengths(metaLength);
}
add(type, meta);
}
}
Aggregations