string - 从网页读取 REST API 端点 - 使用 JAVA
问题描述
我正在实现一个 OIDC 客户端,我想从该网页读取其余端点。
https://login.bbmri-eric.eu/oidc/.well-known/openid-configuration
例如,我的应用程序应该有密钥authorization_endpoint
,它应该从上面提到的 url 中读取这个密钥的值。
有没有一种方法/库可以在没有太多字符串检查的情况下从这样的网页中读取?
解决方案
如果你https://login.bbmri-eric.eu/oidc/.well-known/openid-configuration
在浏览器中点击,你会得到一个 json,如下所示。正如评论中提到的,您所需要的只是下面的代码。
如何在 java 中读取 json - 许多选项之一是包含 Apache Commons IOUtils 和 json.org 库(下载 maven 依赖项)。
JSONObject jsonObject = new JSONObject(IOUtils.toString(new URL("https://login.bbmri-eric.eu/oidc/.well-known/openid-configuration"), Charset.forName("UTF-8")));
如果下面的 JSON,现在这个 jsonObject 是 java 表示。我希望你知道如何使用 java 对象。如果您没有阅读本指南或查看此主题链接
-- 你的 JSON--
{
"request_parameter_supported": true,
"claims_parameter_supported": false,
"introspection_endpoint": "https://login.bbmri-eric.eu/oidc/introspect",
"scopes_supported": [
"openid",
"offline_access"
],
"issuer": "https://login.bbmri-eric.eu/oidc/",
"userinfo_encryption_enc_values_supported": [
"A256CBC+HS512",
"A256GCM",
"A192GCM",
"A128GCM",
"A128CBC-HS256",
"A192CBC-HS384",
"A256CBC-HS512",
"A128CBC+HS256"
],
"id_token_encryption_enc_values_supported": [
"A256CBC+HS512",
"A256GCM",
"A192GCM",
"A128GCM",
"A128CBC-HS256",
"A192CBC-HS384",
"A256CBC-HS512",
"A128CBC+HS256"
],
"authorization_endpoint": "https://login.bbmri-eric.eu/oidc/authorize",
"service_documentation": "https://login.bbmri-eric.eu/oidc/about",
"request_object_encryption_enc_values_supported": [
"A256CBC+HS512",
"A256GCM",
"A192GCM",
"A128GCM",
"A128CBC-HS256",
"A192CBC-HS384",
"A256CBC-HS512",
"A128CBC+HS256"
],
"device_authorization_endpoint": "https://login.bbmri-eric.eu/oidc/devicecode",
"userinfo_signing_alg_values_supported": [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"ES256",
"ES384",
"ES512",
"PS256",
"PS384",
"PS512"
],
"claims_supported": [
"sub",
"name",
"preferred_username",
"given_name",
"family_name",
"middle_name",
"nickname",
"profile",
"picture",
"website",
"gender",
"zoneinfo",
"locale",
"updated_at",
"birthdate",
"email",
"email_verified",
"phone_number",
"phone_number_verified",
"address"
],
"claim_types_supported": [
"normal"
],
"op_policy_uri": "https://login.bbmri-eric.eu/oidc/about",
"token_endpoint_auth_methods_supported": [
"client_secret_post",
"client_secret_basic",
"client_secret_jwt",
"private_key_jwt",
"none"
],
"token_endpoint": "https://login.bbmri-eric.eu/oidc/token",
"response_types_supported": [
"code",
"token"
],
"request_uri_parameter_supported": false,
"userinfo_encryption_alg_values_supported": [
"RSA-OAEP",
"RSA-OAEP-256",
"RSA1_5"
],
"grant_types_supported": [
"authorization_code",
"implicit",
"urn:ietf:params:oauth:grant-type:jwt-bearer",
"client_credentials",
"urn:ietf:params:oauth:grant_type:redelegate",
"urn:ietf:params:oauth:grant-type:device_code"
],
"end_session_endpoint": "https://login.bbmri-eric.eu/oidc/endsession",
"revocation_endpoint": "https://login.bbmri-eric.eu/oidc/revoke",
"userinfo_endpoint": "https://login.bbmri-eric.eu/oidc/userinfo",
"token_endpoint_auth_signing_alg_values_supported": [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"ES256",
"ES384",
"ES512",
"PS256",
"PS384",
"PS512"
],
"op_tos_uri": "https://login.bbmri-eric.eu/oidc/about",
"require_request_uri_registration": false,
"code_challenge_methods_supported": [
"plain",
"S256"
],
"id_token_encryption_alg_values_supported": [
"RSA-OAEP",
"RSA-OAEP-256",
"RSA1_5"
],
"jwks_uri": "https://login.bbmri-eric.eu/oidc/jwk",
"subject_types_supported": [
"public",
"pairwise"
],
"id_token_signing_alg_values_supported": [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"ES256",
"ES384",
"ES512",
"PS256",
"PS384",
"PS512",
"none"
],
"registration_endpoint": "https://login.bbmri-eric.eu/oidc/register",
"request_object_signing_alg_values_supported": [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"ES256",
"ES384",
"ES512",
"PS256",
"PS384",
"PS512"
],
"request_object_encryption_alg_values_supported": [
"RSA-OAEP",
"RSA-OAEP-256",
"RSA1_5"
]
}
推荐阅读
- c# - 我可以将表单上的 Invoke 方法传递给另一个类吗?
- mysql - 选择列的下一个值,其中最后一次出现的特定值在 SQL 的不同列中找到
- react-native - AWS Amplify 不安全吗?
- c - struct epoll_event memset 还是没有 memset?
- c# - 使用 Flurl 将流响应发布和保存到文件的正确方法是什么
- amazon-web-services - 如何解析 AWS EC2 的主机名
- javascript - 按下输入JQuery时如何关闭移动键盘
- google-data-studio - 匹配列表中的关键字并使用正则表达式或其他过滤掉其余关键字?
- javascript - 有没有办法让背景向下滚动,而某些内容始终停留在中间?
- mysql - 根据多个条件和 JOINS 一对多求和