use of org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaOID 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);
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaOID in project core by jcryptool.
the class FlexiProviderRootElement method initSecretKeyAlgorithms.
@SuppressWarnings("unchecked")
private static void initSecretKeyAlgorithms(RegistryType type, Element secretKeyAlgorithmParent) {
List<Element> cipherChildren = new ArrayList<Element>(secretKeyAlgorithmParent.getChildren());
Iterator<Element> it = cipherChildren.iterator();
while (it.hasNext()) {
Element current = it.next();
// replace element with blockCipherElement
String className = current.getAttributeValue(AlgorithmsXMLConstants._class);
IMetaOID oid = null;
if (current.getAttributeValue(AlgorithmsXMLConstants._oid) != null) {
oid = new MetaOID(current.getAttributeValue(AlgorithmsXMLConstants._oid));
}
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());
}
}
IMetaAlgorithm meta = new MetaAlgorithm(type, oid, names, className);
// parameter specs
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec) != null) {
meta.setParameterSpecClassName(current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttributeValue(AlgorithmsXMLConstants._class));
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttribute(AlgorithmsXMLConstants._disabled) == null) {
meta.setParameterSpecDisabled(true);
}
}
// 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));
}
if (current.getChild(AlgorithmsXMLConstants._BlockLengths) != null) {
meta.setDefaultBlockLength(Integer.valueOf(current.getChild(AlgorithmsXMLConstants._BlockLengths).getAttributeValue(AlgorithmsXMLConstants._default)));
if (current.getChild(AlgorithmsXMLConstants._BlockLengths).getText() != null) {
List<Integer> blockLengths = new ArrayList<Integer>(0);
StringTokenizer tokenizer = // $NON-NLS-1$
new StringTokenizer(current.getChild(AlgorithmsXMLConstants._BlockLengths).getText(), ",");
while (tokenizer.hasMoreTokens()) {
blockLengths.add(Integer.valueOf(tokenizer.nextToken()));
}
meta.setBlockLengths(blockLengths);
}
}
if (current.getChild(AlgorithmsXMLConstants._StandardParameters) != null) {
StringTokenizer standardParams = // $NON-NLS-1$
new StringTokenizer(current.getChildText(AlgorithmsXMLConstants._StandardParameters), ",");
while (standardParams.hasMoreTokens()) {
meta.addStandardParams(standardParams.nextToken());
}
}
if (type.equals(RegistryType.MAC)) {
if (current.getChild(AlgorithmsXMLConstants._BlockCipherReference) != null) {
meta.setBlockCipherName(current.getChild(AlgorithmsXMLConstants._BlockCipherReference).getAttributeValue(AlgorithmsXMLConstants._name));
if (current.getChild(AlgorithmsXMLConstants._BlockCipherReference).getAttributeValue(AlgorithmsXMLConstants._oid) != null) {
meta.setBlockCipherOID(new MetaOID(current.getChild(AlgorithmsXMLConstants._BlockCipherReference).getAttributeValue(AlgorithmsXMLConstants._oid)));
}
meta.setBlockCipherMode(current.getChild(AlgorithmsXMLConstants._BlockCipherReference).getAttributeValue(AlgorithmsXMLConstants._mode));
}
}
if (current.getAttribute(AlgorithmsXMLConstants._disabled) == null) {
add(type, meta);
}
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaOID in project core by jcryptool.
the class FlexiProviderRootElement method initAlgorithms.
@SuppressWarnings("unchecked")
private static void initAlgorithms(RegistryType type, Element algorithmParent) {
List<Element> messageDigestChildren = new ArrayList<Element>(algorithmParent.getChildren());
Iterator<Element> it = messageDigestChildren.iterator();
while (it.hasNext()) {
Element current = it.next();
// replace element with blockCipherElement
String className = current.getAttributeValue(AlgorithmsXMLConstants._class);
IMetaOID oid = null;
if (current.getAttributeValue(AlgorithmsXMLConstants._oid) != null) {
oid = new MetaOID(current.getAttributeValue(AlgorithmsXMLConstants._oid));
}
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());
}
}
IMetaAlgorithm meta = new MetaAlgorithm(type, oid, names, className);
// // parameter specs
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec) != null) {
meta.setParameterSpecClassName(current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttributeValue(AlgorithmsXMLConstants._class));
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttribute(AlgorithmsXMLConstants._disabled) == null) {
meta.setParameterSpecDisabled(true);
}
}
// 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));
}
if (current.getChild(AlgorithmsXMLConstants._StandardParameters) != null) {
StringTokenizer standardParams = // $NON-NLS-1$
new StringTokenizer(current.getChildText(AlgorithmsXMLConstants._StandardParameters), ",");
while (standardParams.hasMoreTokens()) {
meta.addStandardParams(standardParams.nextToken());
}
}
if (current.getAttribute(AlgorithmsXMLConstants._disabled) == null) {
add(type, meta);
}
}
}
use of org.jcryptool.crypto.flexiprovider.descriptors.meta.interfaces.IMetaOID in project core by jcryptool.
the class FlexiProviderRootElement method initKeyPairAlgorithms.
@SuppressWarnings("unchecked")
private static void initKeyPairAlgorithms(RegistryType type, Element keyPairAlgorithmParent) {
List<Element> signatureChildren = new ArrayList<Element>(keyPairAlgorithmParent.getChildren());
Iterator<Element> it = signatureChildren.iterator();
while (it.hasNext()) {
Element current = it.next();
String className = current.getAttributeValue(AlgorithmsXMLConstants._class);
IMetaOID oid = null;
if (current.getAttributeValue(AlgorithmsXMLConstants._oid) != null) {
oid = new MetaOID(current.getAttributeValue(AlgorithmsXMLConstants._oid));
}
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());
}
}
IMetaAlgorithm meta = new MetaAlgorithm(type, oid, names, className);
// parameter specs
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec) != null) {
meta.setParameterSpecClassName(current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttributeValue(AlgorithmsXMLConstants._class));
if (current.getChild(AlgorithmsXMLConstants._ParameterSpec).getAttribute(AlgorithmsXMLConstants._disabled) == null) {
meta.setParameterSpecDisabled(true);
}
}
// 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));
}
if (current.getChild(AlgorithmsXMLConstants._StandardParameters) != null) {
StringTokenizer standardParams = // $NON-NLS-1$
new StringTokenizer(current.getChildText(AlgorithmsXMLConstants._StandardParameters), ",");
while (standardParams.hasMoreTokens()) {
meta.addStandardParams(standardParams.nextToken());
}
}
if (current.getAttribute(AlgorithmsXMLConstants._disabled) == null) {
add(type, meta);
}
}
}
Aggregations