{"id":38604905,"url":"https://github.com/singpass/myinfo-connector-java","last_synced_at":"2026-01-17T08:37:07.901Z","repository":{"id":49119251,"uuid":"250201886","full_name":"singpass/myinfo-connector-java","owner":"singpass","description":"MyInfo Connector (Java)","archived":false,"fork":false,"pushed_at":"2024-03-11T07:08:39.000Z","size":33,"stargazers_count":5,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-11T08:29:28.494Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/singpass.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-03-26T08:30:26.000Z","updated_at":"2024-03-11T08:29:31.544Z","dependencies_parsed_at":"2024-03-11T08:29:31.230Z","dependency_job_id":"4a411dcd-9023-4fec-88ea-5fbbe48e771d","html_url":"https://github.com/singpass/myinfo-connector-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/singpass/myinfo-connector-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singpass%2Fmyinfo-connector-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singpass%2Fmyinfo-connector-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singpass%2Fmyinfo-connector-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singpass%2Fmyinfo-connector-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/singpass","download_url":"https://codeload.github.com/singpass/myinfo-connector-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/singpass%2Fmyinfo-connector-java/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504370,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T08:37:07.761Z","updated_at":"2026-01-17T08:37:07.863Z","avatar_url":"https://github.com/singpass.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MyInfo Connector for Java\r\n\r\nMyInfo Connector aims to simplify consumer's integration effort with MyInfo by providing an easy to use Java library to integrate into your application.\r\n\r\n## Requirements\r\n\r\nJava 1.7 and later\r\n\r\n### 1.1 Maven Installation\r\n\r\nAdd the following to your application's pom.xml\r\n\r\n```xml\r\n\u003cdependency\u003e\r\n\t\u003cgroupId\u003eMyInfoConnector-1.0.jar\u003c/groupId\u003e\r\n\t\u003cartifactId\u003eMyInfoConnector-1.0.jar\u003c/artifactId\u003e\r\n\t\u003cscope\u003esystem\u003c/scope\u003e\r\n\t\u003cversion\u003e1.0\u003c/version\u003e\r\n\t\u003csystemPath\u003e${basedir}\\src\\main\\webapp\\WEB-INF\\lib\\MyInfoConnector-1.0.jar\u003c/systemPath\u003e\r\n\u003c/dependency\u003e\r\n```\r\n\r\n### 1.2 Import Connector\r\n\r\nImport the MyInfoConnector.java into your code as below:\r\n\r\n```java\r\nimport sg.gov.ndi.MyInfoConnector;\r\n```\r\n\r\n### 1.3 Properties file\r\nYou are required to create a properties file with the following properties for this library. Samples of the properties file can be found in this repository under the Sample Properties folder.\r\n| Required Properties | Description |\r\n| -------- | ----------- |\r\n| KEYSTORE | Absolute path of the Java keystore that store all the private/public keys. |\r\n| KEYSTORE_PASSPHRASE | Password of your Java keystore. |\r\n| KEYSTORE_PRIVATE_KEY_PASSPHRASE | Password of the private key. |\r\n| PRIVATE_KEY_ALIAS | Alias of the private key in the Java keystore. |\r\n| PUBLIC_CERT_ALIAS | Alias of the MyInfo public certificate in the Java keystore. |\r\n| CLIENT_ID | Unique ID provided upon approval of your application to use MyInfo. For our sample application, it is **STG2-MYINFO-SELF-TEST** |\r\n| CLIENT_SECRET | Secret key provided upon approval of your application to use MyInfo. For our sample application, it is **44d953c796cccebcec9bdc826852857ab412fbe2** |\r\n| REDIRECT_URL | The callback URL specified when invoking the authorise call. For our sample application, it is http://localhost:3001/callback |\r\n| ATTRIBUTES | Comma separated list of attributes requested. Possible attributes are listed in the Person object definition in the API specifications. |\r\n| ENVIRONMENT | The environment your application is configured. This can be **SANDBOX**, **TEST** or **PROD**. |\r\n| TOKEN_URL | Specify the TOKEN API URL for MyInfo. The API is available in three environments:\u003cbr\u003e SANDBOX: **https://sandbox.api.myinfo.gov.sg/com/v3/token**\u003cbr\u003e TEST: **https://test.api.myinfo.gov.sg/com/v3/token**\u003cbr\u003e PROD:  **https://api.myinfo.gov.sg/com/v3/token** |\r\n| PERSON_URL | Specify the TOKEN API URL for MyInfo. The API is available in three environments:\u003cbr\u003e SANDBOX: **https://sandbox.api.myinfo.gov.sg/com/v3/person**\u003cbr\u003e TEST: **https://test.api.myinfo.gov.sg/com/v3/person**\u003cbr\u003e PROD:  **https://api.myinfo.gov.sg/com/v3/person** |\r\n| USE_PROXY | Indicate the use of proxy url. It can be either **Y** or **N**. |\r\n| PROXY_TOKEN_URL | If you are using a proxy url, specify the proxy URL for TOKEN API here. |\r\n| PROXY_PERSON_URL | If you are using a proxy url, specify the proxy URL for PERSON API here. |\r\n\r\n## How to use the connector\r\n\r\n### 1. Get a single instance of MyInfoConnector\r\n\r\nGet a single instance of MyInfoConnector and load properties file:\r\n\r\n```\r\nMyInfoConnector connector = MyInfoConnector.getInstance(\"C:\\\\MyInfoConnectorPROD.properties\");\r\n```\r\n\r\nOnce the properties file are loaded, you may retrieve the instance again with the below method:\r\n```\r\nMyInfoConnector connector = MyInfoConnector.getCurrentInstance();\r\n```\r\n\r\n### 2. Retrieve person's data\r\nRetrieve person's data by passing the authorisation code and state from the Authorise API call:\r\n\r\n```\r\nconnector.getMyInfoPersonData(authCode,state);\r\n```\r\n**txnNo** is an optional parameter that can be passed through the overloaded method, if required.\r\n```\r\nconnector.getMyInfoPersonData(authCode,txnNo,state);\r\n```\r\n\r\n## Helper methods\r\n\r\nUnder the hood, MyInfoConnector make use of **MyInfoSecurityHelper** and you may use the class as util methods to meet your application needs.\r\n\r\n### 1. Forming the Signature Base String\r\nThis method takes in the API call method (GET, POST, etc.), API URL, and all the required parameters into a treemap, sort them and form the base string.\r\n```\r\nMyInfoSecurityHelper.generateBaseString(method, urlProp, baseParams);\r\n```\r\n\r\n### 2. Generating the Signature\r\nThis method takes in the base string and the private key to sign and generate the signature.\r\n```\r\nMyInfoSecurityHelper.generateSignature(baseString, privateKey);\r\n```\r\n\r\n### 3. Assembling the Header\r\nThis method takes in all the required parameters into a treemap and assemble the header.\r\n```\r\nMyInfoSecurityHelper.generateAuthorizationHeader(authHeaderParams);\r\n```\r\nIt also provide an overloaded method that takes in the bearer token, if required.\r\n```\r\nMyInfoSecurityHelper.generateAuthorizationHeader(authHeaderParams, bearer);\r\n```\r\n\r\n### 4. Decrypting and retrieving the Payload\r\nThis method takes in the result from the **person** API call  and the private key to decrypt and retrieve the payload.\r\n```\r\nMyInfoSecurityHelper.getPayload(result, privateKey);\r\n```\r\n\r\n### 5. Verify Token\r\nThis method takes in the decrypted payload and the public key to verify the token.\r\n```\r\nMyInfoSecurityHelper.verifyToken(decryptedPayload, pubKey);\r\n```\r\n\r\n## Reporting issues\r\n\r\nYou may contact [support@myinfo.gov.sg](mailto:support@myinfo.gov.sg) for any other technical issues, and we will respond to you within 5 working days.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingpass%2Fmyinfo-connector-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsingpass%2Fmyinfo-connector-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsingpass%2Fmyinfo-connector-java/lists"}