001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2021, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.openid.connect.sdk.federation.trust.marks; 019 020 021import java.net.URI; 022 023import net.minidev.json.JSONObject; 024 025import com.nimbusds.oauth2.sdk.ParseException; 026import com.nimbusds.oauth2.sdk.util.JSONObjectUtils; 027 028 029/** 030 * Trust mark issuer metadata. 031 * 032 * <p>Related specifications: 033 * 034 * <ul> 035 * <li>OpenID Connect Federation 1.0. 036 * </ul> 037 */ 038@Deprecated 039public class TrustMarkIssuerMetadata { 040 041 042 /** 043 * The federation status endpoint. 044 */ 045 private final URI federationStatusEndpoint; 046 047 048 /** 049 * Creates a new trust mark issuer metadata. 050 * 051 * @param federationStatusEndpoint The federation status endpoint, 052 * {@code null} if not specified. 053 */ 054 public TrustMarkIssuerMetadata(final URI federationStatusEndpoint) { 055 this.federationStatusEndpoint = federationStatusEndpoint; 056 } 057 058 059 /** 060 * Gets the federation status endpoint URI. Corresponds to the 061 * {@code federation_status_endpoint} metadata field. 062 * 063 * @return The federation status endpoint URI, {@code null} if not 064 * specified. 065 */ 066 public URI getFederationStatusEndpointURI() { 067 return federationStatusEndpoint; 068 } 069 070 071 /** 072 * Returns a JSON object representation of this trust mark issuer 073 * metadata. 074 * 075 * <p>Example: 076 * 077 * <pre> 078 * { 079 * "endpoint": "https://trust_marks_are_us.example.com/status" 080 * } 081 * </pre> 082 * 083 * @return The JSON object. 084 */ 085 public JSONObject toJSONObject() { 086 087 JSONObject o = new JSONObject(); 088 if (getFederationStatusEndpointURI() != null) { 089 o.put("federation_status_endpoint", getFederationStatusEndpointURI().toString()); 090 } 091 return o; 092 } 093 094 095 /** 096 * Parses a trust mark issuer metadata from the specified JSON object. 097 * 098 * <p>Example: 099 * 100 * <pre> 101 * { 102 * "endpoint": "https://trust_marks_are_us.example.com/status" 103 * } 104 * </pre> 105 * 106 * @param jsonObject The JSON object. Must not be {@code null}. 107 * 108 * @return The trust mark issuer metadata. 109 * 110 * @throws ParseException If parsing failed. 111 */ 112 public static TrustMarkIssuerMetadata parse(final JSONObject jsonObject) 113 throws ParseException { 114 115 return new TrustMarkIssuerMetadata( 116 JSONObjectUtils.getURI(jsonObject, "federation_status_endpoint", null) 117 ); 118 } 119 120 121 /** 122 * Parses a trust mark issuer metadata from the specified JSON object 123 * string. 124 * 125 * <p>Example: 126 * 127 * <pre> 128 * { 129 * "endpoint": "https://trust_marks_are_us.example.com/status" 130 * } 131 * </pre> 132 * 133 * @param json The JSON object string. Must not be {@code null}. 134 * 135 * @return The trust mark issuer metadata. 136 * 137 * @throws ParseException If parsing failed. 138 */ 139 public static TrustMarkIssuerMetadata parse(final String json) 140 throws ParseException { 141 142 return parse(JSONObjectUtils.parse(json)); 143 } 144}