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.assurance.evidences; 019 020 021import java.util.Objects; 022 023import net.minidev.json.JSONObject; 024 025import com.nimbusds.oauth2.sdk.ParseException; 026import com.nimbusds.openid.connect.sdk.assurance.claims.CountryCode; 027import com.nimbusds.openid.connect.sdk.claims.Address; 028 029 030/** 031 * Electronic record source. 032 * 033 * <p>Related specifications: 034 * 035 * <ul> 036 * <li>OpenID Connect for Identity Assurance 1.0, section 5.1.1.2. 037 * </ul> 038 */ 039public class ElectronicRecordSource extends CommonOriginatorAttributes { 040 041 042 /** 043 * Creates a new electronic record source. 044 * 045 * @param name The source name, {@code null} if not specified. 046 * @param address The source address elements, {@code null} if not 047 * specified. 048 * @param countryCode The source country code, {@code null} if not 049 * specified. 050 * @param jurisdiction The source jurisdiction, {@code null} if not 051 * specified. 052 */ 053 public ElectronicRecordSource(final Name name, 054 final Address address, 055 final CountryCode countryCode, 056 final Jurisdiction jurisdiction) { 057 058 super(name, address, countryCode, jurisdiction); 059 } 060 061 062 @Override 063 public boolean equals(Object o) { 064 if (this == o) return true; 065 if (!(o instanceof ElectronicRecordSource)) return false; 066 ElectronicRecordSource that = (ElectronicRecordSource) o; 067 return Objects.equals( 068 getName(), that.getName()) && 069 Objects.equals(getAddress(), that.getAddress()) && 070 Objects.equals(getCountryCode(), that.getCountryCode()) && 071 Objects.equals(getJurisdiction(), that.getJurisdiction()); 072 } 073 074 075 /** 076 * Parses an electronic record source from the specified JSON object. 077 * 078 * @param jsonObject The JSON object. Must not be {@code null}. 079 * 080 * @return The electronic record source. 081 * 082 * @throws ParseException If parsing failed. 083 */ 084 public static ElectronicRecordSource parse(final JSONObject jsonObject) 085 throws ParseException { 086 087 CommonOriginatorAttributes commonOriginatorAttributes = CommonOriginatorAttributes.parse(jsonObject); 088 089 return new ElectronicRecordSource( 090 commonOriginatorAttributes.getName(), 091 commonOriginatorAttributes.getAddress(), 092 commonOriginatorAttributes.getCountryCode(), 093 commonOriginatorAttributes.getJurisdiction() 094 ); 095 } 096}