use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class CarManager method load.
public void load(Element root) {
// new format using elements starting version 3.3.1
if (root.getChild(Xml.NEW_KERNELS) != null) {
@SuppressWarnings("unchecked") List<Element> eKernels = root.getChild(Xml.NEW_KERNELS).getChildren(Xml.KERNEL);
log.debug("Car manager sees {} kernels", eKernels.size());
Attribute a;
for (Element eKernel : eKernels) {
if ((a = eKernel.getAttribute(Xml.NAME)) != null) {
newKernel(a.getValue());
}
}
} else // old format
if (root.getChild(Xml.KERNELS) != null) {
String names = root.getChildText(Xml.KERNELS);
if (!names.equals("")) {
// NOI18N
String[] kernelNames = names.split("%%");
log.debug("kernels: {}", names);
for (String name : kernelNames) {
newKernel(name);
}
}
}
if (root.getChild(Xml.CARS) != null) {
@SuppressWarnings("unchecked") List<Element> eCars = root.getChild(Xml.CARS).getChildren(Xml.CAR);
log.debug("readFile sees {} cars", eCars.size());
for (Element eCar : eCars) {
register(new Car(eCar));
}
}
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class TrainCustomCommon method load.
public void load(Element mc) {
if (mc != null) {
Attribute a;
Element directory = mc.getChild(Xml.DIRECTORY);
if (directory != null && (a = directory.getAttribute(Xml.NAME)) != null) {
setDirectoryName(a.getValue());
}
Element file = mc.getChild(Xml.RUN_FILE);
if (file != null && (a = file.getAttribute(Xml.NAME)) != null) {
mcAppName = a.getValue();
}
Element common = mc.getChild(Xml.COMMON_FILE);
if (common != null && (a = common.getAttribute(Xml.NAME)) != null) {
csvNamesFileName = a.getValue();
}
}
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class PaneProgFrame method pickProgrammerMode.
protected void pickProgrammerMode(@Nonnull Element programming) {
log.debug("pickProgrammerMode starts");
boolean paged = true;
boolean directbit = true;
boolean directbyte = true;
boolean register = true;
Attribute a;
// set the programming attributes for DCC
if ((a = programming.getAttribute("paged")) != null) {
if (a.getValue().equals("no")) {
paged = false;
}
}
if ((a = programming.getAttribute("direct")) != null) {
if (a.getValue().equals("no")) {
directbit = false;
directbyte = false;
} else if (a.getValue().equals("bitOnly")) {
directbit = true;
directbyte = false;
} else if (a.getValue().equals("byteOnly")) {
directbit = false;
directbyte = true;
} else {
directbit = true;
directbyte = true;
}
}
if ((a = programming.getAttribute("register")) != null) {
if (a.getValue().equals("no")) {
register = false;
}
}
// find an accepted mode to set it to
List<ProgrammingMode> modes = mProgrammer.getSupportedModes();
if (log.isDebugEnabled()) {
log.debug("XML specifies modes: P " + paged + " DBi " + directbit + " Dby " + directbyte + " R " + register + " now " + mProgrammer.getMode());
log.debug("Programmer supports:");
for (ProgrammingMode m : modes) {
log.debug(" {} {}", m.getStandardName(), m.toString());
}
}
// first try specified modes
for (Element el1 : programming.getChildren("mode")) {
String name = el1.getText();
if (log.isDebugEnabled())
log.debug(" mode {} was specified", name);
for (ProgrammingMode m : modes) {
if (name.equals(m.getStandardName())) {
log.info("Programming mode selected: {} ({})", m.toString(), m.getStandardName());
mProgrammer.setMode(m);
return;
}
}
}
if (modes.contains(DefaultProgrammerManager.DIRECTMODE) && directbit && directbyte) {
mProgrammer.setMode(DefaultProgrammerManager.DIRECTMODE);
log.debug("Set to DIRECTMODE");
} else if (modes.contains(DefaultProgrammerManager.DIRECTBITMODE) && directbit) {
mProgrammer.setMode(DefaultProgrammerManager.DIRECTBITMODE);
log.debug("Set to DIRECTBITMODE");
} else if (modes.contains(DefaultProgrammerManager.DIRECTBYTEMODE) && directbyte) {
mProgrammer.setMode(DefaultProgrammerManager.DIRECTBYTEMODE);
log.debug("Set to DIRECTBYTEMODE");
} else if (modes.contains(DefaultProgrammerManager.PAGEMODE) && paged) {
mProgrammer.setMode(DefaultProgrammerManager.PAGEMODE);
log.debug("Set to PAGEMODE");
} else if (modes.contains(DefaultProgrammerManager.REGISTERMODE) && register) {
mProgrammer.setMode(DefaultProgrammerManager.REGISTERMODE);
log.debug("Set to REGISTERMODE");
} else {
log.warn("No acceptable mode found, leave as found");
}
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class PaneProgFrame method loadProgrammerFile.
protected void loadProgrammerFile(RosterEntry r) {
// Open and parse programmer file
XmlFile pf = new XmlFile() {
};
// XmlFile is abstract
try {
programmerRoot = pf.rootFromName(filename);
// get the showEmptyPanes attribute, if yes/no update our state
if (programmerRoot.getChild("programmer").getAttribute("showEmptyPanes") != null) {
if (log.isDebugEnabled()) {
log.debug("Found in programmer " + programmerRoot.getChild("programmer").getAttribute("showEmptyPanes").getValue());
}
programmerShowEmptyPanes = programmerRoot.getChild("programmer").getAttribute("showEmptyPanes").getValue();
} else {
programmerShowEmptyPanes = "";
}
if (log.isDebugEnabled()) {
log.debug("programmerShowEmptyPanes=" + programmerShowEmptyPanes);
}
// get extra any panes from the decoder file
Attribute a;
if ((a = programmerRoot.getChild("programmer").getAttribute("decoderFilePanes")) != null && a.getValue().equals("yes")) {
if (decoderRoot != null) {
decoderPaneList = decoderRoot.getChildren("pane");
}
}
// load programmer config from programmer tree
readConfig(programmerRoot, r);
} catch (org.jdom2.JDOMException e) {
log.error("exception parsing programmer file: " + filename, e);
// provide traceback too
e.printStackTrace();
} catch (java.io.IOException e) {
log.error("exception reading programmer file: " + filename, e);
// provide traceback too
e.printStackTrace();
}
}
use of org.bouncycastle.asn1.x509.Attribute in project ddf by codice.
the class SubjectUtils method getAttribute.
/**
* Get any attribute from a subject by key.
*
* @param subject
* @param key
* @return attribute values or an empty list if not found.
*/
public static List<String> getAttribute(@Nullable Subject subject, String key) {
Validate.notNull(key);
if (subject == null) {
LOGGER.debug("Incoming subject was null, cannot look up {}.", key);
return Collections.emptyList();
}
PrincipalCollection principals = subject.getPrincipals();
if (principals == null) {
LOGGER.debug("No principals located in the incoming subject, cannot look up {}.", key);
return Collections.emptyList();
}
SecurityAssertion assertion = principals.oneByType(SecurityAssertion.class);
if (assertion == null) {
LOGGER.debug("Could not find Security Assertion, cannot look up {}.", key);
return Collections.emptyList();
}
return assertion.getAttributeStatements().stream().flatMap(as -> as.getAttributes().stream()).filter(a -> a.getName().equals(key)).flatMap(a -> a.getAttributeValues().stream()).filter(o -> o instanceof XSString).map(o -> (XSString) o).map(XSString::getValue).collect(Collectors.toList());
}
Aggregations