{"id":13821698,"url":"https://github.com/signalapp/libsignal-service-java","last_synced_at":"2025-05-16T13:30:47.111Z","repository":{"id":27988113,"uuid":"31482103","full_name":"signalapp/libsignal-service-java","owner":"signalapp","description":"A Java/Android library for communicating with the Signal messaging service.","archived":true,"fork":false,"pushed_at":"2024-07-25T14:30:33.000Z","size":1682,"stargazers_count":584,"open_issues_count":29,"forks_count":270,"subscribers_count":56,"default_branch":"master","last_synced_at":"2024-08-05T08:09:45.913Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/signalapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-03-01T00:38:58.000Z","updated_at":"2024-08-01T12:59:08.000Z","dependencies_parsed_at":"2024-01-15T15:39:34.019Z","dependency_job_id":"8fed29dd-d78c-4a8c-8b6e-8528bfe2a7b7","html_url":"https://github.com/signalapp/libsignal-service-java","commit_stats":null,"previous_names":["whispersystems/libtextsecure-java","whispersystems/libsignal-service-java"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/signalapp%2Flibsignal-service-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/signalapp%2Flibsignal-service-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/signalapp%2Flibsignal-service-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/signalapp%2Flibsignal-service-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/signalapp","download_url":"https://codeload.github.com/signalapp/libsignal-service-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225431071,"owners_count":17473296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-04T08:01:26.246Z","updated_at":"2024-11-19T21:31:28.633Z","avatar_url":"https://github.com/signalapp.png","language":"Java","funding_links":[],"categories":["Java","网络编程"],"sub_categories":["Spring Cloud框架"],"readme":"# signal-service-java\n\nA Java library for communicating via Signal.\n\n## Implementing the Signal Protocol interfaces\n\nThe Signal encryption protocol is a stateful protocol, so libsignal-service users\nneed to implement the storage interface `SignalProtocolStore`, which handles load/store\nof your key and session information to durable media.\n\n## Creating keys\n\n`````java\nIdentityKeyPair    identityKey        = KeyHelper.generateIdentityKeyPair();\nList\u003cPreKeyRecord\u003e oneTimePreKeys     = KeyHelper.generatePreKeys(0, 100);\nPreKeyRecord       lastResortKey      = KeyHelper.generateLastResortPreKey();\nSignedPreKeyRecord signedPreKeyRecord = KeyHelper.generateSignedPreKey(identityKey, signedPreKeyId);\n`````\n\nThe above are then stored locally so that they're available for load via the `SignalProtocolStore`.\n\n## Registering\n\nAt install time, clients need to register with the Signal server.\n\n`````java\nprivate final String     URL         = \"https://my.signal.server.com\";\nprivate final TrustStore TRUST_STORE = new MyTrustStoreImpl();\nprivate final String     USERNAME    = \"+14151231234\";\nprivate final String     PASSWORD    = generateRandomPassword();\nprivate final String     USER_AGENT  = \"[FILL_IN]\";\n\nSignalServiceAccountManager accountManager = new SignalServiceAccountManager(URL, TRUST_STORE,\n                                                                             USERNAME, PASSWORD, USER_AGENT);\n\naccountManager.requestSmsVerificationCode();\naccountManager.verifyAccountWithCode(receivedSmsVerificationCode, generateRandomSignalingKey(),\n                                     generateRandomInstallId(), false);\naccountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));\naccountManager.setPreKeys(identityKey.getPublicKey(), lastResortKey, signedPreKeyRecord, oneTimePreKeys);\n`````\n\n## Sending text messages\n\n`````java\nSignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, USERNAME, PASSWORD,\n                                                                          new MySignalProtocolStore(),\n                                                                          USER_AGENT, Optional.absent());\n\nmessageSender.sendMessage(new SignalServiceAddress(\"+14159998888\"),\n                          SignalServiceDataMessage.newBuilder()\n                                                  .withBody(\"Hello, world!\")\n                                                  .build());\n`````\n\n## Sending media messages\n\n`````java\nSignalServiceMessageSender messageSender = new SignalServiceMessageSender(URL, TRUST_STORE, USERNAME, PASSWORD,\n                                                                          new MySignalProtocolStore(),\n                                                                          USER_AGENT, Optional.absent());\n\nFile                    myAttachment     = new File(\"/path/to/my.attachment\");\nFileInputStream         attachmentStream = new FileInputStream(myAttachment);\nSignalServiceAttachment attachment       = SignalServiceAttachment.newStreamBuilder()\n                                                                  .withStream(attachmentStream)\n                                                                  .withContentType(\"image/png\")\n                                                                  .withLength(myAttachment.length())\n                                                                  .build();\n\nmessageSender.sendMessage(new SignalServiceAddress(\"+14159998888\"),\n                          SignalServiceDataMessage.newBuilder()\n                                                  .withBody(\"An attachment!\")\n                                                  .withAttachment(attachment)\n                                                  .build());\n\n`````\n\n## Receiving messages\n\n`````java\nSignalServiceMessageReceiver messageReceiver = new SignalServiceMessageReceiver(URL, TRUST_STORE, USERNAME,\n                                                                                PASSWORD, mySignalingKey,\n                                                                                USER_AGENT);\nSignalServiceMessagePipe     messagePipe     = null;\n\ntry {\n  messagePipe = messageReceiver.createMessagePipe();\n\n  while (listeningForMessages) {\n    SignalServiceEnvelope envelope = messagePipe.read(timeout, timeoutTimeUnit);\n    SignalServiceCipher   cipher   = new SignalServiceCipher(new SignalServiceAddress(USERNAME),\n                                                             new MySignalProtocolStore());\n    SignalServiceContent  message  = cipher.decrypt(envelope);\n\n    System.out.println(\"Received message: \" + message.getDataMessage().get().getBody().get());\n  }\n\n} finally {\n  if (messagePipe != null)\n    messagePipe.shutdown();\n}\n`````\n\n# Legal things\n\n## Cryptography Notice\n\nThis distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software.\nBEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted.\nSee \u003chttp://www.wassenaar.org/\u003e for more information.\n\nThe U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms.\nThe form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.\n\n## License\n\nCopyright 2013-2016 Open Whisper Systems\n\nLicensed under the AGPLv3: https://www.gnu.org/licenses/agpl-3.0.html\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsignalapp%2Flibsignal-service-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsignalapp%2Flibsignal-service-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsignalapp%2Flibsignal-service-java/lists"}