001/* 002 * Copyright 2024 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.auth.camara; 017 018import com.vonage.client.QueryParamsRequest; 019import com.vonage.client.common.E164; 020import java.net.URI; 021import java.util.LinkedHashMap; 022import java.util.Map; 023import java.util.Objects; 024 025/** 026 * Base request query parameters for the intermediate three-legged OAuth2 check network authentication. 027 */ 028public abstract class AuthRequest implements QueryParamsRequest { 029 final Map<String, String> params = new LinkedHashMap<>(8); 030 031 /** 032 * Creates the base auth request parameters. 033 * 034 * @param msisdn The phone number of the user you want to authenticate in E.164 format. 035 * @param scope The scope of the request as an enum. 036 */ 037 protected AuthRequest(String msisdn, FraudPreventionDetectionScope scope) { 038 params.put("login_hint", "tel:+" + new E164(msisdn)); 039 params.put("scope", "openid dpv:FraudPreventionAndDetection#" + 040 Objects.requireNonNull(scope, "Scope is required.") 041 ); 042 } 043 044 @Override 045 public final Map<String, String> makeParams() { 046 return params; 047 } 048}