mirror of
https://github.com/google/nomulus.git
synced 2025-05-14 00:17:20 +02:00
Inject RdapAuthorization
We currently create it from injected arguments, and pass it to every function. Instead, we just create a provider for it and inject it where needed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=247072517
This commit is contained in:
parent
ce7456ea66
commit
3b8a8892bb
10 changed files with 70 additions and 102 deletions
|
@ -91,6 +91,7 @@ public class RdapJsonFormatter {
|
|||
@Inject @Config("rdapTos") ImmutableList<String> rdapTos;
|
||||
@Inject @Config("rdapTosStaticUrl") @Nullable String rdapTosStaticUrl;
|
||||
@Inject @FullServletPath String fullServletPath;
|
||||
@Inject RdapAuthorization rdapAuthorization;
|
||||
@Inject RdapJsonFormatter() {}
|
||||
|
||||
/**
|
||||
|
@ -216,15 +217,12 @@ public class RdapJsonFormatter {
|
|||
* port43 field; if null, port43 is not added to the object
|
||||
* @param now the as-date
|
||||
* @param outputDataType whether to generate full or summary data
|
||||
* @param authorization the authorization level of the request; if not authorized for the
|
||||
* registrar owning the domain, no contact information is included
|
||||
*/
|
||||
RdapDomain makeRdapJsonForDomain(
|
||||
DomainBase domainBase,
|
||||
@Nullable String whoisServer,
|
||||
DateTime now,
|
||||
OutputDataType outputDataType,
|
||||
RdapAuthorization authorization) {
|
||||
OutputDataType outputDataType) {
|
||||
RdapDomain.Builder builder = RdapDomain.builder();
|
||||
// RDAP Response Profile 15feb19 section 2.2:
|
||||
// The domain handle MUST be the ROID
|
||||
|
@ -238,7 +236,7 @@ public class RdapJsonFormatter {
|
|||
builder.linksBuilder().add(
|
||||
makeSelfLink("domain", domainBase.getFullyQualifiedDomainName()));
|
||||
boolean displayContacts =
|
||||
authorization.isAuthorizedForClientId(domainBase.getCurrentSponsorClientId());
|
||||
rdapAuthorization.isAuthorizedForClientId(domainBase.getCurrentSponsorClientId());
|
||||
// If we are outputting all data (not just summary data), also add information about hosts,
|
||||
// contacts and events (history entries). If we are outputting summary data, instead add a
|
||||
// remark indicating that fact.
|
||||
|
@ -271,8 +269,7 @@ public class RdapJsonFormatter {
|
|||
Optional.of(designatedContact.getType()),
|
||||
null,
|
||||
now,
|
||||
outputDataType,
|
||||
authorization))
|
||||
outputDataType))
|
||||
.forEach(builder.entitiesBuilder()::add);
|
||||
}
|
||||
builder
|
||||
|
@ -394,18 +391,15 @@ public class RdapJsonFormatter {
|
|||
* port43 field; if null, port43 is not added to the object
|
||||
* @param now the as-date
|
||||
* @param outputDataType whether to generate full or summary data
|
||||
* @param authorization the authorization level of the request; personal contact data is only
|
||||
* shown if the contact is owned by a registrar for which the request is authorized
|
||||
*/
|
||||
RdapEntity makeRdapJsonForContact(
|
||||
ContactResource contactResource,
|
||||
Optional<DesignatedContact.Type> contactType,
|
||||
@Nullable String whoisServer,
|
||||
DateTime now,
|
||||
OutputDataType outputDataType,
|
||||
RdapAuthorization authorization) {
|
||||
OutputDataType outputDataType) {
|
||||
boolean isAuthorized =
|
||||
authorization.isAuthorizedForClientId(contactResource.getCurrentSponsorClientId());
|
||||
rdapAuthorization.isAuthorizedForClientId(contactResource.getCurrentSponsorClientId());
|
||||
|
||||
RdapEntity.Builder entityBuilder =
|
||||
RdapEntity.builder()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue