use of com.epri._2016.cimidentities_.Name in project jasn1 by openmuc.
the class GeneralName method decode.
public int decode(InputStream is, BerTag berTag) throws IOException {
int codeLength = 0;
BerTag passedTag = berTag;
if (berTag == null) {
berTag = new BerTag();
codeLength += berTag.decode(is);
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 0)) {
otherName = new AnotherName();
codeLength += otherName.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) {
rfc822Name = new BerIA5String();
codeLength += rfc822Name.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 2)) {
dNSName = new BerIA5String();
codeLength += dNSName.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 3)) {
x400Address = new ORAddress();
codeLength += x400Address.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 4)) {
codeLength += BerLength.skip(is);
directoryName = new Name();
codeLength += directoryName.decode(is, null);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 5)) {
ediPartyName = new EDIPartyName();
codeLength += ediPartyName.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 6)) {
uniformResourceIdentifier = new BerIA5String();
codeLength += uniformResourceIdentifier.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 7)) {
iPAddress = new BerOctetString();
codeLength += iPAddress.decode(is, false);
return codeLength;
}
if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 8)) {
registeredID = new BerObjectIdentifier();
codeLength += registeredID.decode(is, false);
return codeLength;
}
if (passedTag != null) {
return 0;
}
throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item.");
}
use of com.epri._2016.cimidentities_.Name in project CIM-Identities by epri-dev.
the class CIMIdentitiesClient method enterButtonActionPerformed.
// GEN-LAST:event_refreshButtonActionPerformed
private void enterButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_enterButtonActionPerformed
n_nameNew = n_nameBox.getText();
nt_nameNew = nt_nameBox.getText();
nt_desNew = nt_desBox.getText();
nta_nameNew = nta_nameBox.getText();
nta_desNew = nta_desBox.getText();
String mRID = enter_uuidBox.getText();
ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType msg = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType();
/* create payload object out of parsed data */
CIMIdentitiesPayloadType payload = new CIMIdentitiesPayloadType();
// create new CIMIdentities object
CIMIdentities cimids = new CIMIdentities();
CIMIdentity cimid = new CIMIdentity();
payload.setCIMIdentities(cimids);
// creates new ArrayList of CIMIdentities
ArrayList<CIMIdentity> cim = (ArrayList<CIMIdentity>) payload.getCIMIdentities().getCIMIdentity();
// set mRID
IdentifiedObject value = new IdentifiedObject();
value.setMRID(mRID);
cimid.setIdentifiedObject(value);
// set name
Name name = new Name();
name.setName(n_nameNew);
if (Delete.isSelected())
name.setName("");
if (name.getName() == null)
name.setName("");
cimid.getNames().add(name);
// set NameType name/description
NameType nameType = new NameType();
nameType.setDescription(nt_desNew);
if (Delete.isSelected())
nameType.setDescription("");
if (nameType.getDescription() == null)
nameType.setDescription("");
nameType.setName(nt_nameNew);
if (Delete.isSelected())
nameType.setName("");
if (nameType.getName() == null)
nameType.setName("");
cimid.getNames().get(0).setNameType(nameType);
// set NameTypeAuthority name/description
NameTypeAuthority nameTypeAuth = new NameTypeAuthority();
nameTypeAuth.setDescription(nta_desNew);
if (Delete.isSelected())
nameTypeAuth.setDescription("");
if (nameTypeAuth.getDescription() == null)
nameTypeAuth.setDescription("");
nameTypeAuth.setName(nta_nameNew);
if (Delete.isSelected())
nameTypeAuth.setName("");
if (nameTypeAuth.getName() == null)
nameTypeAuth.setDescription("");
cimid.getNames().get(0).getNameType().setNameTypeAuthority(nameTypeAuth);
cim.add(cimid);
msg.setPayload(payload);
/* Insertion handling */
if (Insert.isSelected()) {
if (gen_uuidSel.isSelected()) {
value.setMRID("");
payload.getCIMIdentities().getCIMIdentity().get(0).setIdentifiedObject(value);
msg.setPayload(payload);
}
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("create");
msg.setHeader(header);
try {
createdCIMIdentitiesRequest(msg);
JOptionPane.showMessageDialog(null, "Data inserted:\n\n" + "\nName: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "\nNameType Name: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "\nNameType Description: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "\nNameTypeAuthority Name: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "\nNameTypeAuthority Description: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription());
} catch (FaultMessage ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(CIMIdentitiesClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
/* deletion handling */
if (Delete.isSelected() && enter_uuidSel.isSelected()) {
uuidEntered = true;
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("delete");
msg.setHeader(header);
/* query the server for the mRID being deleted */
CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
CIMIdentitiesQueries var = new CIMIdentitiesQueries();
EndDeviceGroup edg = new EndDeviceGroup();
// can be null, '?', or '""' to receive all data, else set mRID
edg.setMRID(mRID);
message.setRequest(request);
message.getRequest().setCIMIdentitiesQueries(var);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
try {
response = queryCIMIdentities(message);
} catch (QueryCIMIdentitiesFaultMessage ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
/* set outgoing deletion message to contain ALL data about the mRID */
msg.getPayload().setCIMIdentities(response.getPayload().getCIMIdentities());
try {
if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
throw new IndexOutOfBoundsException("mRID doesn't exist");
deletedCIMIdentitiesRequest(msg);
JOptionPane.showMessageDialog(null, "Data deleted:\n\n" + "mRID: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "\nName: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "\nNameType Name: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "\nNameType Description: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "\nNameTypeAuthority Name: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "\nNameTypeAuthority Description: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription());
} catch (FaultMessage ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(CIMIdentitiesClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (IndexOutOfBoundsException err) {
JOptionPane.showMessageDialog(null, "No deletion made.\nUUID does not currently exist in the database.\n");
}
}
/* modification handling */
if (Modify.isSelected()) {
HeaderType header = new HeaderType();
header.setNoun("CIMIdentities");
header.setVerb("change");
msg.setHeader(header);
/* query the server for the mRID being modified */
CIMIdentitiesQueriesRequestType request = new CIMIdentitiesQueriesRequestType();
CIMIdentitiesQueries var = new CIMIdentitiesQueries();
EndDeviceGroup edg = new EndDeviceGroup();
// can be null, '?', or '""' to receive all data, else set mRID
edg.setMRID(mRID);
message.setRequest(request);
message.getRequest().setCIMIdentitiesQueries(var);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup().add(0, edg);
message.getRequest().getCIMIdentitiesQueries().getEndDeviceGroup();
try {
response = queryCIMIdentities(message);
} catch (QueryCIMIdentitiesFaultMessage ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(CIMIdentitiesClient.class.getName()).log(Level.SEVERE, null, ex);
}
try {
if (response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() == null)
throw new IndexOutOfBoundsException("mRID doesn't exist");
changedCIMIdentitiesRequest(msg);
JOptionPane.showMessageDialog(null, "Data modified:\n\n" + "mRID: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().getMRID() + "\nPrevious Name: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "\nPrevious NameType Name: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "\nPrevious NameType Description: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "\nPrevoius NameTypeAuthority Name: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "\nPrevious NameTypeAuthority Description: " + response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription() + "\n\n\nNew Name: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getName() + "\nNew NameType Name: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getName() + "\nNew NameType Description: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getDescription() + "\nNew NameTypeAuthority Name: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName() + "\nNew NameTypeAuthority Description: " + msg.getPayload().getCIMIdentities().getCIMIdentity().get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription());
} catch (FaultMessage ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
Logger.getLogger(CIMIdentitiesClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (IndexOutOfBoundsException err) {
JOptionPane.showMessageDialog(null, "No modification made.\nUUID does not currently exist in the database.\n");
}
}
n_nameBox.setText("");
nt_nameBox.setText("");
nt_desBox.setText("");
nta_nameBox.setText("");
nta_desBox.setText("");
enter_uuidBox.setText("");
n_name.removeAllItems();
nt_namecb.removeAllItems();
nt_descb.removeAllItems();
nta_namecb.removeAllItems();
nta_descb.removeAllItems();
createTable();
populateComboBoxes();
}
use of com.epri._2016.cimidentities_.Name in project CIM-Identities by epri-dev.
the class CIMIdentitiesClient method createTable.
public void createTable() {
curPage = Integer.parseInt(curPageBox.getText());
if (numRowsBox.getText().equals("")) {
JOptionPane.showMessageDialog(null, "Number of rows field is empty\nPlease input desired value");
return;
}
numRows = Integer.parseInt(numRowsBox.getText());
if (!totalPageBox.getText().equals("")) {
totalPage = Integer.parseInt(totalPageBox.getText());
if (curPage > totalPage) {
JOptionPane.showMessageDialog(null, "Invalid page number\n");
curPage = totalPage;
curPageBox.setText(Integer.toString(curPage));
createTable();
}
}
int index = 0;
DefaultTableModel Model = new DefaultTableModel();
Object[] colName = new Object[6];
colName[0] = "mRID";
colName[1] = "Name";
colName[2] = "NT Name";
colName[3] = "NT Des";
colName[4] = "NTA Name";
colName[5] = "NTA Des";
Model.setColumnIdentifiers(colName);
createResponse();
Object[] rowData = new Object[6];
for (int i = 0; i < responseSize; i++) {
rowData[0] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getIdentifiedObject().getMRID();
rowData[1] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getNames().get(0).getName();
rowData[2] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getNames().get(0).getNameType().getName();
rowData[3] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getNames().get(0).getNameType().getDescription();
rowData[4] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getNames().get(0).getNameType().getNameTypeAuthority().getName();
rowData[5] = response.getPayload().getCIMIdentities().getCIMIdentity().get(i).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
Model.addRow(rowData);
}
// now we add obtain the total number of rows:
int totalRows = Model.getRowCount();
// using that total number of rows, we computer the number of pages
totalPage = (totalRows / numRows) + 1;
totalPageBox.setText(Integer.toString(totalPage));
// move index to starting value in current page
index = ((curPage - 1) * numRows);
// now loop through the result set adding to new model
DefaultTableModel newModel = new DefaultTableModel();
newModel.setColumnIdentifiers(colName);
if ((curPage != totalPage) && (curPage < totalPage) && (curPage >= 1)) {
for (int i = numRows; i > 0; i--) {
rowData[0] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getIdentifiedObject().getMRID();
rowData[1] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getName();
rowData[2] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getName();
rowData[3] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getDescription();
rowData[4] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getNameTypeAuthority().getName();
rowData[5] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
newModel.addRow(rowData);
index++;
}
} else if (curPage == totalPage) {
for (int i = (totalRows % numRows); i > 0; i--) {
rowData[0] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getIdentifiedObject().getMRID();
rowData[1] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getName();
rowData[2] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getName();
rowData[3] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getDescription();
rowData[4] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getNameTypeAuthority().getName();
rowData[5] = response.getPayload().getCIMIdentities().getCIMIdentity().get(index).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
newModel.addRow(rowData);
index++;
}
} else {
JOptionPane.showMessageDialog(null, "Invalid page number");
return;
}
dataTable = new javax.swing.JTable();
dataTable.setModel(newModel);
jScrollPane3.setViewportView(dataTable);
}
use of com.epri._2016.cimidentities_.Name in project CIM-Identities by epri-dev.
the class CIMIdentities method createdCIMIdentitiesRequest.
public ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType createdCIMIdentitiesRequest(ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesEventMessageType message) throws ClassNotFoundException {
ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType response = new ch.iec.tc57._2016.cimidentitiesmessage.CIMIdentitiesResponseMessageType();
// Event message type only contains the header/payload
// Response message type contains header/payload/reply
// therefore, response message type must be set for CIMIdentitiesResponseMessageType
ReplyType value = new ReplyType();
// String result = value.getResult();
value.setResult("OK");
// set response header/payload/reply
response.setHeader(message.getHeader());
response.setPayload(message.getPayload());
response.setReply(value);
// extract individual values for insertion into database
ArrayList<CIMIdentity> cim = (ArrayList<CIMIdentity>) response.getPayload().getCIMIdentities().getCIMIdentity();
mRID = cim.get(0).getIdentifiedObject().getMRID();
NName = cim.get(0).getNames().get(0).getName();
NTName = cim.get(0).getNames().get(0).getNameType().getName();
NTDes = cim.get(0).getNames().get(0).getNameType().getDescription();
NTAName = cim.get(0).getNames().get(0).getNameType().getNameTypeAuthority().getName();
NTADes = cim.get(0).getNames().get(0).getNameType().getNameTypeAuthority().getDescription();
try {
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(host, uName, password);
Statement stmt = con.createStatement();
// as uuidEntered == false
if (mRID.equals("") || mRID.equals("?")) {
String genUUID = "INSERT INTO public.\"Identity\" (id_pkey, entry)" + "VALUES (DEFAULT, DEFAULT)";
stmt.executeUpdate(genUUID);
String getUUID = "SELECT id.id_pkey FROM \"Identity\" id " + "ORDER BY id.entry desc LIMIT 1";
ResultSet rs = stmt.executeQuery(getUUID);
rs.next();
mRID = rs.getString("id_pkey");
response.getPayload().getCIMIdentities().getCIMIdentity().get(0).getIdentifiedObject().setMRID(mRID);
} else {
String entUUID = "INSERT INTO public.\"Identity\"(id_pkey, entry)" + "VALUES ('" + mRID + "', DEFAULT)";
stmt.executeUpdate(entUUID);
}
String insertIDObj = "INSERT INTO public.\"IdentifiedObject\"(io_pkey)" + "VALUES('" + mRID + "')";
String insertName = "INSERT INTO public.\"Name\"(n_pkey, n_name)" + "VALUES('" + mRID + "', '" + NName + "')";
String insertNT = "INSERT INTO public.\"NameType\"(nt_pkey, nt_description, nt_name)" + "VALUES ('" + mRID + "', '" + NTDes + "', '" + NTName + "')";
String insertNTA = "INSERT INTO public.\"NameTypeAuthority\"(nta_pkey, nta_name, nta_description)" + "VALUES ('" + mRID + "', '" + NTAName + "', '" + NTADes + "')";
stmt.executeUpdate(insertIDObj);
stmt.executeUpdate(insertName);
stmt.executeUpdate(insertNT);
stmt.executeUpdate(insertNTA);
stmt.close();
con.close();
return response;
} catch (SQLException err) {
value.setResult("FAILED");
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
err.printStackTrace(pw);
value.getError().get(0).setDetails(sw.toString());
response.setReply(value);
return response;
}
}
use of com.epri._2016.cimidentities_.Name in project XobotOS by xamarin.
the class X509CRLSelector method setIssuerNames.
/**
* <b>Do not use:</b> use {@link #setIssuers(Collection)} or one of
* {@link #addIssuerName} instead. Sets the criterion for the issuer
* distinguished names.
* <p>
* The CRL issuer must match at least one of the specified distinguished
* names.
* <p>
* The specified parameter {@code names} is a collection with an entry for
* each name to be included in the criterion. The name is specified as a
* {@code String} or a byte array specifying the name (in RFC 2253 or ASN.1
* DER encoded form)
*
* @param names
* the list of issuer distinguished names to match, or {@code
* null} if any issuer distinguished name will do.
* @throws IOException
* if parsing fails.
*/
public void setIssuerNames(Collection<?> names) throws IOException {
if (names == null) {
issuerNames = null;
issuerPrincipals = null;
return;
}
if (names.size() == 0) {
return;
}
issuerNames = new ArrayList<String>(names.size());
for (Object name : names) {
if (name instanceof String) {
issuerNames.add(new Name((String) name).getName(X500Principal.CANONICAL));
} else if (name instanceof byte[]) {
issuerNames.add(new Name((byte[]) name).getName(X500Principal.CANONICAL));
} else {
throw new IOException("name neither a String nor a byte[]");
}
}
}
Aggregations