summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--src/test/java/at/gv/util/demo/Clienttests.java687
2 files changed, 2 insertions, 688 deletions
diff --git a/.gitignore b/.gitignore
index 78cc1d0..ef1ce5d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
target
.settings
.svn
-wsdlsources \ No newline at end of file
+wsdlsources
+/src/test/java/at/gv/util/demo/Clienttests.java
diff --git a/src/test/java/at/gv/util/demo/Clienttests.java b/src/test/java/at/gv/util/demo/Clienttests.java
deleted file mode 100644
index b2f90ae..0000000
--- a/src/test/java/at/gv/util/demo/Clienttests.java
+++ /dev/null
@@ -1,687 +0,0 @@
-package at.gv.util.demo;
-
-import iaik.security.ecc.interfaces.ECDSAParams;
-import iaik.security.ecc.interfaces.ECDSAPublicKey;
-import iaik.security.ecc.math.ecgroup.AffineCoordinate;
-import iaik.security.ecc.math.ecgroup.ECPoint;
-import iaik.security.ecc.provider.ECCProvider;
-import iaik.x509.X509Certificate;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.PublicKey;
-import java.security.cert.CertificateException;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.ECPublicKey;
-import java.security.interfaces.RSAPublicKey;
-import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.regex.Pattern;
-
-import javax.xml.bind.JAXBElement;
-import javax.xml.namespace.QName;
-import javax.xml.transform.TransformerException;
-
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.cxf.common.util.Base64Utility;
-import org.apache.cxf.helpers.IOUtils;
-import org.w3c.dom.Element;
-
-import at.gv.util.BpkUtil;
-import at.gv.util.DOMUtils;
-import at.gv.util.MiscUtil;
-import at.gv.util.client.mis.usp_v2.USPClient;
-import at.gv.util.client.mis_v2.MISV2Client;
-import at.gv.util.client.mms.MMSClient;
-import at.gv.util.client.szr.SZRClient;
-import at.gv.util.client.ur_V5.URClient;
-import at.gv.util.client.ur_V5.URClient.URSearchResult;
-import at.gv.util.client.ur_V5.URClientException;
-import at.gv.util.config.EgovUtilPropertiesConfiguration;
-import at.gv.util.data.BPK;
-import at.gv.util.ex.EgovUtilException;
-import at.gv.util.wsdl.mis_v2.GetMandatesError;
-import at.gv.util.wsdl.szr.SZRException;
-import at.gv.util.xsd.mis_v2.GetMandatesRequestType;
-import at.gv.util.xsd.mis_v2.GetMandatesResponseType;
-import at.gv.util.xsd.mis_v2.PersonInformationType;
-import at.gv.util.xsd.mis_v2.persondata.IdentificationType.Value;
-import at.gv.util.xsd.mms.GetMandatesRequest;
-import at.gv.util.xsd.mms.GetMandatesRequest.MandateIdentifiers;
-import at.gv.util.xsd.mms.GetMandatesResponse;
-import at.gv.util.xsd.szr.FremdBPKType;
-import at.gv.util.xsd.szr.GetIdentityLink;
-import at.gv.util.xsd.szr.IdentityLinkType;
-import at.gv.util.xsd.szr.PersonInfoType;
-import at.gv.util.xsd.szr.TravelDocumentType;
-import at.gv.util.xsd.szr.ecdsa.DomainParamsType;
-import at.gv.util.xsd.szr.ecdsa.ECDSAKeyValueType;
-import at.gv.util.xsd.szr.ecdsa.ECPointType;
-import at.gv.util.xsd.szr.ecdsa.NamedCurveType;
-import at.gv.util.xsd.szr.ecdsa.PrimeFieldElemType;
-import at.gv.util.xsd.szr.persondata.DeliveryAddressType;
-import at.gv.util.xsd.szr.persondata.IdentificationType;
-import at.gv.util.xsd.szr.persondata.PersonNameType;
-import at.gv.util.xsd.szr.persondata.PhysicalPersonType;
-import at.gv.util.xsd.szr.persondata.PostalAddressType;
-import at.gv.util.xsd.szr.xmldsig.DSAKeyValueType;
-import at.gv.util.xsd.szr.xmldsig.KeyValueType;
-import at.gv.util.xsd.szr.xmldsig.RSAKeyValueType;
-import at.gv.util.xsd.ur_V5.pd.NichtNatuerlichePersonTyp;
-
-public class Clienttests {
-
- public static String XFN_NAME = "Firmenbuchnummer";
- public static String XFN_VALUE = "urn:publicid:gv.at:baseid+XFN";
- public static String XFN_URT = "FBN";
-
- public static String XZVR_NAME = "ZVR-Zahl";
- public static String XZVR_VALUE = "urn:publicid:gv.at:baseid+XZVR";
- public static String XZVR_URT = "ZVR";
-
- public static String XERSB_NAME = "ERsB Ordnungsnummer";
- public static String XERSB_VALUE = "urn:publicid:gv.at:baseid+XERSB";
- public static String XERSB_URT = "ERJ";
-
- public static List<String> UR_TYPES = Arrays.asList(XFN_URT, XZVR_URT, XERSB_URT);
-
- public static HashSet<String> ERSB_KEYS = new HashSet<String>();
-
- public static final String SSPIN_PREFIX = "urn:publicid:gv.at:cdid+";
-
- private final static byte[] DEFAULT_PUBL_KEY = new byte[] {48, -127, -97, 48, 13, 6, 9, 42, -122, 72, -122, -9, 13, 1, 1, 1, 5, 0, 3, -127, -115, 0, 48, -127, -119, 2, -127, -127, 0, -106, 114, -113, -1, -84, 116, 35, 3, 70, -81, 81, -110, -10, -59, 114, 4, -109, 86, 127, -50, 125, 47, 4, 80, 79, 53, 117, -36, 15, -16, -61, 110, 39, 89, 29, -43, 37, -127, 80, -109, -38, 65, 125, -119, 44, -111, -21, 47, -98, 38, -112, -24, 107, -110, 17, -10, 51, -4, -36, -72, -28, -18, -14, 117, -67, 76, -31, 32, 92, 104, -21, 68, 31, -12, 30, -104, -104, 42, -107, 126, 84, 50, 85, -117, 44, -100, -4, 102, -100, 52, -68, 77, -32, 9, -16, -30, -104, -90, 107, -88, 7, 97, -94, 72, -61, -40, 80, -112, -65, -25, -72, -19, -95, -54, 31, 15, 24, -105, 123, -81, 23, -123, 92, -103, -101, 47, 47, -105, 2, 3, 1, 0, 1};
- public static final String DOCUMENT_TYPE = "ELEKTR_DOKUMENT";
- public static final String ERnB_ISSUEDATE = "2014-01-01";
- public static final String ERnB_ISSUINGAUTHORITY = "SZR-Gateway";
-
- public final static Pattern URN_PATTERN = Pattern.compile(
- "^urn:[a-z0-9][a-z0-9-]{0,31}:([a-z0-9()+,\\-.:=@;$_!*']|%[0-9a-f]{2})+$",
- Pattern.CASE_INSENSITIVE);
-
- @SuppressWarnings("unused")
- public static void main(String[] args) throws IOException {
-
- String propertiesFileLocation = System.getProperty("mis.configuration");
-
- if (propertiesFileLocation == null) {
- System.out.println("No system properties found. Cannot load default configuration.");
- throw new IOException("Cannot load default configuration. Please specify first mis.configuration location in system properties.");
-
- }
-
- File propertiesFile = new File(propertiesFileLocation);
- FileInputStream fis = new FileInputStream(propertiesFile);
- String configDir = propertiesFile.getParentFile().getAbsolutePath();
- Properties props = new Properties();
- props.load(fis);
-
- EgovUtilPropertiesConfiguration egovUtilConfiguration = new EgovUtilPropertiesConfiguration(props, configDir);
-
- ERSB_KEYS.add("136");
- ERSB_KEYS.add("137");
- ERSB_KEYS.add("138");
- ERSB_KEYS.add("139");
- ERSB_KEYS.add("140");
-
- try {
- SZRClient szrClient = new SZRClient(egovUtilConfiguration);
- URClient urClient = new URClient(egovUtilConfiguration, UR_TYPES, ERSB_KEYS, false, true);
- MMSClient mmsClient = new MMSClient(egovUtilConfiguration);
- MISV2Client misV2Client = new MISV2Client(egovUtilConfiguration);
-
-
- PersonInfoType personInfo = new PersonInfoType();
- PhysicalPersonType person = new PhysicalPersonType();
- personInfo.setPerson(person);
- PersonNameType personName = new PersonNameType();
- person.setName(personName );
-
- IdentificationType id = new IdentificationType();
- PostalAddressType address = new PostalAddressType();
-
-
-// id.setType(SSPIN_PREFIX + "ZP");
-// id.setValue("U/wThc0XOTZp9Tvsxrh8DhGTXsU=");
-// person.setIdentification(id);
-
-// personName.setFamilyName("Lenz");
-// personName.setGivenName("Thomas");
-// person.setDateOfBirth("1982-09-06");
-
-// personName.setFamilyName("XXXTüzekçi");
-// personName.setGivenName("XXXŐzgür");
-// person.setDateOfBirth("1973-06-04");
-
-// personName.setFamilyName("Tauber");
-// personName.setGivenName("Arne");
-// person.setDateOfBirth("1979-08-21");
-//
-// personName.setFamilyName("ALLMBlasznig ELGATest");
-// personName.setGivenName("Reinfried");
-// person.setDateOfBirth("1943-06-26");
-//
-// personName.setFamilyName("Buxbaum");
-// personName.setGivenName("Georg");
-// person.setDateOfBirth("1964-10-09");
-//
-// personName.setFamilyName("Eder");
-// personName.setGivenName("Michaela");
-// person.setDateOfBirth("1971-04-25");
-// id.setType(SSPIN_PREFIX + "ZP");
-// id.setValue("T2wnifoq7CJDyhhWod7+YiZilLA=");
-// person.setIdentification(id);
-
-// personName.setFamilyName("Buxbaum");
-// personName.setGivenName("Doris");
-// person.setDateOfBirth("1976-05-26");
-
-// personName.setFamilyName("Lackner");
-// personName.setGivenName("Christiane");
-// person.setDateOfBirth("1965-04-22");
-
-// personName.setFamilyName("Karning");
-// personName.setGivenName("Bernhard");
-// person.setDateOfBirth("1976-01-15");
-
-// personName.setFamilyName("Müller");
-// personName.setGivenName("Harald");
-// person.setDateOfBirth("1964-10-30");
-// personInfo.setRegularDomicile(address );
-// address.setPostalCode("1130");
-
-// personName.setFamilyName("Rudinger");
-// personName.setGivenName("Franz");
-// person.setDateOfBirth("1973-04-18");
-
-// personName.setFamilyName("Drabina");
-// personName.setGivenName("Sonja");
-// person.setDateOfBirth("1969-09-23");
-
-// personName.setFamilyName("Pointner");
-// personName.setGivenName("Johann");
-//// person.setDateOfBirth("1954-07-07");
-// personInfo.setRegularDomicile(address);
-// DeliveryAddressType delivAddr = new DeliveryAddressType();
-//// address.setMunicipality("Linz");
-// //address.setLocality("Wels");
-// address.setPostalCode("4030");
-
-
-// String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZP-MH", "BKA");
-// String bpks = szrClient.getBPK(personInfo, SSPIN_PREFIX + "ZU", "BBA-STA");
-//
-//
-
- //InputStream is = Clienttests.class.getResourceAsStream("/clearing_geburtstage_mit_UTC_versatz_20180214.csv");
-// InputStream is = Clienttests.class.getResourceAsStream("/clearing_geburtstage_mit_UTC_versatz_20180305.csv");
-// String data = IOUtils.toString(is);
-// for (String line : data.split("\\n")) {
-// try {
-// String[] el = line.split(",");
-//
-// personName.setFamilyName(el[4]);
-// personName.setGivenName(el[3]);
-//
-// String date = el[5].substring(1, el[5].length()-1);
-// Date test = MiscUtil.parseDate(date, "yyyy-MM-dd", TimeZone.getTimeZone("UTC"));
-// Date tomorrow = new Date(test.getTime() + (1000 * 60 * 60 * 24));
-// person.setDateOfBirth(MiscUtil.formatDate(tomorrow, "yyyy-MM-dd"));
-//
-//
-// String baseID = szrClient.getStammzahl(personInfo );
-// System.out.println("OK!!! " + person.getName().getGivenName() + " " + person.getName().getFamilyName());
-//
-//
-// } catch ( Exception e) {
-// e.printStackTrace();
-// }
-//
-//
-// }
-
-
-
-
-// personName.setFamilyName("Hembach");
-// personName.setGivenName("Alfred");
-// person.setDateOfBirth("1975-03-02");
-//
-// personName.setFamilyName("Atzlinger");
-// personName.setGivenName("Manfred");
-// person.setDateOfBirth("1964-01-29");
-//
-// personName.setFamilyName("Doppler");
-// personName.setGivenName("Dominik");
-// person.setDateOfBirth("1998-04-14");
-
-
- ///Datenschutzbehörde
-
-// personName.setFamilyName("Wollrab");
-// personName.setGivenName("Michael");
-// person.setDateOfBirth("1981-04-27");
-
-// personName.setFamilyName("Sollinger");
-// personName.setGivenName("Moritz");
-// //person.setDateOfBirth("1997-08-09");
-// IdentificationType eid = new IdentificationType();
-// eid.setType("urn:publicid:gv.at:cdid+ZP");
-// eid.setValue("gd4u4WNDjV3xBYMcuBmj2vwhH88=");
-// person.setIdentification(eid );
-//
-// personName.setFamilyName("Ruzizka");
-// personName.setGivenName("Nina Christina");
-// person.setDateOfBirth("1982-08-27");
-
-// personName.setFamilyName("El Fohail");
-// personName.setGivenName("Samraa");
-// person.setDateOfBirth("1975-01-13");
-
-// personName.setFamilyName("Allwgeppert Elgatest");
-// personName.setGivenName("Amèlîè");
-// person.setDateOfBirth("1943-07-03");
-
- personName.setFamilyName("Mustermann");
- personName.setGivenName("Max");
- person.setDateOfBirth("1940-01-01");
-// id.setType(SSPIN_PREFIX + "ZP");
-// id.setValue("nOuO8JELgLMCke6qWSAfNSDPPcM=");
- id.setType(SSPIN_PREFIX + "ZU");
- id.setValue("NEK/9ZsnA7e2phK71F/OSdIjwbU=");
- person.setIdentification(id);
-
-// personName.setFamilyName("Hiptmair");
-// personName.setGivenName("Karl");
- //person.setDateOfBirth("1968-04-07");
-// id.setType(SSPIN_PREFIX + "ZU");
-// id.setValue("WlDEwRwleyT9gyCRedqhL+vNmBs=");
-
-// id.setType(SSPIN_PREFIX + "ZP");
-// id.setValue("OzlNpKPY4oFt10uu0dQ55G/uaCE=");
-
- person.setIdentification(id);
-
-
- //*************************************
- //MIS v2.0 test
- GetMandatesRequestType getMandatesRequest = new GetMandatesRequestType();
- getMandatesRequest.setReqId(RandomStringUtils.randomAlphabetic(10));
- PersonInformationType pInfo = new PersonInformationType();
- pInfo.setDateOfBirth(person.getDateOfBirth());
- pInfo.setGivenName(person.getName().getGivenName());
- pInfo.setFamilyName(person.getName().getFamilyName());
- at.gv.util.xsd.mis_v2.persondata.IdentificationType idType = new at.gv.util.xsd.mis_v2.persondata.IdentificationType();
- idType.setType(person.getIdentification().getType());
- Value idValue = new Value();
- idValue.setValue(person.getIdentification().getValue());
- idType.setValue(idValue );
- pInfo.setIdentification(idType );
- getMandatesRequest.setPersonInformation(pInfo );
-
- try {
- GetMandatesResponseType getMandatesResp = misV2Client.sendMandateIssueRequest(getMandatesRequest, "https://labda.iaik.tugraz.at:5343/mis/services/GetMandatesRequest");
- System.out.println("Get result from MIS v2.0 with #" + getMandatesResp.getMisMandate().size() + " mandates");
-
- } catch (GetMandatesError e) {
- e.printStackTrace();
-
- }
-
- //*************************************
-
- String baseID = szrClient.getStammzahl(personInfo );
-
- BPK zpBpk;
- BPK zuBpk;
- //BPK zuBpk = BpkUtil.createBPK(baseID, "ZU");
- zuBpk = new BPK("ZU", id.getValue());
- zpBpk = new BPK("ZP", id.getValue());
-
-// id.setType(SSPIN_PREFIX + zuBpk.getSector());
-// id.setValue(zuBpk.getBpk());
-// person.setDateOfBirth(null);
-// person.setIdentification(id);
-
-
-
-// BPK zpBpk = BpkUtil.createBPK(baseID, "ZP-MH");
-// System.out.print(zpBpk);
-
-// GetMandatesRequest mmsRequest = new GetMandatesRequest();
-// mmsRequest.setBPK(zpBpk.getBpk());
-// mmsRequest.setBPKType(BpkUtil.PREFIX_BPK_TYPE + "ZU");
-// MandateIdentifiers filters = new MandateIdentifiers();
-// filters.getMandateIdentifier().add("GeneralvollmachtBilateral");
-// mmsRequest.setMandateIdentifiers(filters );
-// GetMandatesResponse mmsResult = mmsClient.sendGetMandatesRequest(mmsRequest, "https://vollmachten.egiz.gv.at/mms-test/services/GetMandatesService");
-
-
-// personInfo.getPerson().setDateOfBirth(null);
-
-// String test = szrClient.getBPK(personInfo, "ZP", "BBA-STA");
- String test = szrClient.getBPK(personInfo, "ZP", "BKA");
- //String test = szrClient.getBPK(personInfo, "ZU", "BKA");
-
-// String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BBA-STA");
-// FremdBPKType encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "WT-UR", "BMF");
- FremdBPKType encryptedbPK = szrClient.transformBPK(personInfo, zuBpk.getBpk(), SSPIN_PREFIX + "ZU", SSPIN_PREFIX + "WT-UR", "BMF");
-// String encryptedbPK = szrClient.transformBPK(personInfo, zpBpk.getBpk(), SSPIN_PREFIX + "ZP", SSPIN_PREFIX + "ZU", "ZUSETNVZ");
-
-
-
- /*
- *USP V2 Client tests
- *
- */
- USPClient uspClient = new USPClient(egovUtilConfiguration, true);
-
-// uspClient.getMandates(
-// encryptedbPK.getBereichsKennung(),
-// encryptedbPK.getFremdBPK(),
-// Arrays.asList("MPK_Postvollmacht"));
-
-// uspClient.getMandates(
-// "urn:publicid:gv.at:ecdid+BMF+WT-UR",
-// "CfAUGvuKyy8q9ZGLKI1WloY3ihkQ3vJis40grN9M6Eud+YU9EDXWkqdsVnznIpHaCc1cCUMA5+YorDhIZyvabxvty8Rwiq3PBHVMVc4/+jjkx2qkqOodM3gOQHG1TsPbSRl7tysCukGpdgK7NJFdh0mTlsYUwLatSsi+Qv0lTYU=",
-// Arrays.asList("MPK_Postvollmacht"));
-
-
-// GetIdentityLink idlReq = createGetIdentityLink();
-////
-/// String baseIDResp = szrClient.getStammzahl(personInfo);
-//////
-// IdentityLinkType idlResp = szrClient.getIdentityLink(
-// idlReq.getPersonInfo(),
-// idlReq.getKeyValue(),
-// true);
-// Element idl = (Element)idlResp.getAssertion();
-// System.out.println(DOMUtils.serializeNode(idl));
-
-// FileOutputStream writeToFile = new FileOutputStream("D:/local_work/zertifikate/ELGA_mocca_testcards/Allwsoker_Elgatest.idl");
-// writeToFile.write(DOMUtils.serializeNode(idl).getBytes());
-// writeToFile.close();
-
-
-// List<NichtNatuerlichePersonTyp> urResult = urClient.searchByRegisterNumber("9110008265019", "ERJ", 10);
- List<NichtNatuerlichePersonTyp> urResult = urClient.searchByRegisterNumber("9110008265019", "ERK", 10);
-
-// urResult = urClient.searchByName("Bundesministerium*", null, 10);
-
-// List<URSearchResult> urResult = urClient.searchByBpk(encryptedbPK);
-// List<URSearchResult> urResult = urClient.searchByRegisterNumberFullInfo("237384w", "FBN", 10);
-
- System.out.println("Finish");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private static GetIdentityLink createGetIdentityLink() throws CertificateException, IOException, InvalidKeyException{
-
- // set parameter
- GetIdentityLink getIdentityLink = new GetIdentityLink();
-
- SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");
- PersonInfoType personInfo = new PersonInfoType();
- PhysicalPersonType physicalPerson = new PhysicalPersonType();
- PostalAddressType address = new PostalAddressType();
-
- // generate PersonData
- PersonNameType personName = new PersonNameType();
-// personName.setFamilyName("Janez Vzorec");
-// personName.setGivenName("Janez Vzorec");
-
-// personName.setFamilyName("ALLWSoker ELGATest");
-// personName.setGivenName("Zilli Winnimar");
-
-// personName.setFamilyName("Pointner");
-// personName.setGivenName("Johann");
-// address.setMunicipality("Linz");
-// address.setPostalCode("4030");
-// String birthday = "1954-07-07";
-// String birthday = "1928-04-10";
-
-// personName.setFamilyName("Lenz");
-// personName.setGivenName("Thomas");
-// String birthday = null;
-// birthday = "1982-09-06";
-// address.setMunicipality("Obdach");
-// address.setPostalCode("8742");
-
-
- personName.setFamilyName("Farbenfroh");
- personName.setGivenName("Jonatan");
- String birthday = null;
- birthday = "1978-08-25";
-
-
-
- if (birthday != null)
- physicalPerson.setDateOfBirth(birthday);
-
- physicalPerson.setName(personName);
-// if (address != null)
-// personInfo.setRegularDomicile(address);
-
- personInfo.setPerson(physicalPerson);
-
- // add Traveldocument
-
- TravelDocumentType trvlDoc = new TravelDocumentType();
-//
-// // parse STORK-eID to his components
-// //ERnB allows only eIDs with a maximum length of 54 signs
- trvlDoc.setDocumentNumber("12345678abcde");
- trvlDoc.setIssuingCountry("SI");
- trvlDoc.setDocumentType(DOCUMENT_TYPE);
-//
-// //set default values from SZR because certificate for mandator natural person is not
-// //available in case of authentication with electronic mandates.
-// trvlDoc.setIssueDate(ERnB_ISSUEDATE);
-// trvlDoc.setIssuingAuthority(ERnB_ISSUINGAUTHORITY);
-//
- JAXBElement<TravelDocumentType> jaxbtrvlDoc = personInfo.getTravelDocument();
-
- if (jaxbtrvlDoc == null)
- jaxbtrvlDoc = new JAXBElement<TravelDocumentType>(new QName("urn:SZRServices", "TravelDocument"), TravelDocumentType.class, trvlDoc);
- else
- jaxbtrvlDoc.setValue(trvlDoc);
-
- personInfo.setTravelDocument(jaxbtrvlDoc);
-
- // Personendaten setzen
- getIdentityLink.setPersonInfo(personInfo);
-
- // add Keys
-
- PublicKey pb;
- List<KeyValueType> keyvalueList = getIdentityLink.getKeyValue();
- if (keyvalueList == null)
- keyvalueList = new ArrayList<KeyValueType>();
-
-
-// InputStream importCertStream = new FileInputStream("F:/local_work/zertifikate/mocca_testcards/BRZ_testcards/test_identities/Achim XXXZastrow/secure.crt");
-// X509Certificate importCert = new X509Certificate(importCertStream );
-// pb = importCert.getPublicKey();
-
- pb = new iaik.security.rsa.RSAPublicKey(DEFAULT_PUBL_KEY);
- List<KeyValueType> keys = getKeyValueTypes(pb);
- keyvalueList.addAll(keys);
-
-// KeyValueType testvalue = new KeyValueType();
-// RSAKeyValueType rsaKeyValue = new RSAKeyValueType();
-// rsaKeyValue.setExponent("Forever");
-// rsaKeyValue.setModulus("Kandi");;
-// testvalue.setRSAKeyValue(rsaKeyValue );
-// keyvalueList.add(testvalue);
-
-
- // set Insert ERnP flag
- getIdentityLink.setInsertERnP(true);
-
-// Constants.DATA_LOGGER.debug("Person wird im SZR und ERnP gesucht bzw. gegebenenfalls im ERnP eingetragen: "
-// + natPerson.getFamilyName() + " " + natPerson.getGivenName() + " " + natPerson.getBirthday()
-// + " eID=" + natPerson.geteID() , tid);
-
- return getIdentityLink;
-
- }
-
- /**
- * Returns the according key value types from the given public key
- * @param pb
- * @return
- * @throws SZRGWException
- */
- private static List<KeyValueType> getKeyValueTypes(PublicKey pb) {
- List<KeyValueType> keys = new ArrayList<KeyValueType>();
-
- ECCProvider.addAsProvider();
-
- //System.out.println(pb);
-
- if (pb instanceof RSAPublicKey) {
- //System.out.println("Is a RSAPublicKey");
- //Extract key data
- RSAPublicKey rsapb = (RSAPublicKey)pb;
-
- BigInteger modulus = rsapb.getModulus();
- BigInteger exponent = rsapb.getPublicExponent();
-
- //System.out.println("Modulus: " + modulus);
- //System.out.println("PublicExponent: " + exponent);
-
- // set key values
- RSAKeyValueType rsa = new RSAKeyValueType();
- ;
- rsa.setExponent(Base64Utility.encode(exponent.toByteArray()));
- rsa.setModulus(Base64Utility.encode(modulus.toByteArray()));
-
-
- KeyValueType key = new KeyValueType();
- key.setRSAKeyValue(rsa);
- keys.add(key);
-
- }
-
- if (pb instanceof DSAPublicKey) {
- //System.out.println("Is a DSAPublicKey");
- // extract key data
- DSAPublicKey dsapb = (DSAPublicKey) pb;
- BigInteger y = dsapb.getY();
- DSAParams param = dsapb.getParams();
- BigInteger g = param.getG();
- BigInteger p = param.getP();
- BigInteger q = param.getQ();
-
-// System.out.println("Y: " + y);
-// System.out.println("G: " + g);
-// System.out.println("P: " + p);
-// System.out.println("Q: " + q);
-//
- //set key values
- DSAKeyValueType dsa = new DSAKeyValueType();
- if (y != null)
- dsa.setY(y.toString());
- if (g != null)
- dsa.setG(g.toString());
- if (p != null)
- dsa.setP(p.toString());
- if (q != null)
- dsa.setQ(q.toString());
-
- KeyValueType key = new KeyValueType();
- key.setDSAKeyValue(dsa);
- keys.add(key);
-
- }
-
- if (pb instanceof ECDSAPublicKey) {
-
- //Extract key data
- ECDSAPublicKey ecdsapb= (ECDSAPublicKey)pb;
- ECDSAParams params = ecdsapb.getParameter();
- //EllipticCurve curve = params.getG().getCurve();
- String oid = params.getOID();
- //String name = ObjectID.getRegisteredName(oid);
- ECPoint w = ecdsapb.getW();
- AffineCoordinate coordinate = (AffineCoordinate) w.getCoordinates().toAffine();
- String x = coordinate.getX().toBigInt().toString();
- String y = coordinate.getY().toBigInt().toString();
-
- ECDSAKeyValueType ecdsa = new ECDSAKeyValueType();
- DomainParamsType paramstype = new DomainParamsType();
- NamedCurveType namedCurve = new NamedCurveType();
- namedCurve.setURN("urn:oid:" + oid);
- paramstype.setNamedCurve(namedCurve);
- ecdsa.setDomainParameters(paramstype);
-
- ECPointType ecpointtype = new ECPointType();
- PrimeFieldElemType xElem = new PrimeFieldElemType();
- xElem.setValue(x);
- PrimeFieldElemType yElem = new PrimeFieldElemType();
- yElem.setValue(y);
- ecpointtype.setX(xElem);
- ecpointtype.setY(yElem);
- ecdsa.setPublicKey(ecpointtype);
-
- KeyValueType key = new KeyValueType();
- key.setECDSAKeyValue(ecdsa);
- keys.add(key);
-
- //throw new SZRGWException("Certificate enthält einen ECDSAPublicKey. Dieser wird momentan noch nicht unterstützt.");
- }
-
- if (pb instanceof ECPublicKey) {
- //System.out.println("Is a ECPublicKey");
-
-
-// throw new SZRGWException("Certificate enthält einen ECPublicKey. Dieser wird momentan noch nicht unterstützt.");
-
-
-
-// ECPublicKey ecpb = (ECPublicKey) pb;
-//
-// System.out.println(ecpb.toString());
-//
-// ECParameterSpec params = ecpb.getParams();
-// EllipticCurve curve = params.getCurve();
-//
-// ECDSAKeyValueType ecdsa = new ECDSAKeyValueType();
-// DomainParamsType domainparams = new DomainParamsType();
-// NamedCurveType curvetype = new NamedCurveType();
-// curvetype.setURN("P-192");
-// domainparams.setNamedCurve(curvetype);
-// ecdsa.setDomainParameters(domainparams);
-// ECPointType publicKey = new ECPointType();
-// PrimeFieldElemType x = new PrimeFieldElemType();
-// x.setValue("12345x");
-// publicKey.setX(x);
-// PrimeFieldElemType y = new PrimeFieldElemType();
-// y.setValue("12345y");
-// publicKey.setY(y);
-// ecdsa.setPublicKey(publicKey);
-// keys[0].setECDSAKeyValue(ecdsa);
-
-
- }
-
- return keys;
- }
-
-}