use of com.emc.storageos.security.authorization.ExcludeLicenseCheck in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method checkIfBehindNat.
/**
* Check Data Replication If Behind NAT
*
* @param checkParam
* @param clientIp
* @brief Check if behind NAT
* @return DRNatCheckResponse
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN }, blockProxies = true)
@Path("/natcheck")
@ExcludeLicenseCheck
public DRNatCheckResponse checkIfBehindNat(DRNatCheckParam checkParam, @HeaderParam("X-Forwarded-For") String clientIp) {
if (checkParam == null) {
log.error("checkParam is null, X-Forwarded-For is {}", clientIp);
throw APIException.internalServerErrors.invalidNatCheckCall("(null)", clientIp);
}
String ipv4Str = checkParam.getIPv4Address();
String ipv6Str = checkParam.getIPv6Address();
log.info(String.format("Performing NAT check, client address connecting to VIP: %s. Client reports its IPv4 = %s, IPv6 = %s", clientIp, ipv4Str, ipv6Str));
boolean isBehindNat = false;
try {
isBehindNat = sysUtils.checkIfBehindNat(ipv4Str, ipv6Str, clientIp);
} catch (Exception e) {
log.error("Fail to check NAT {}", e);
throw APIException.internalServerErrors.invalidNatCheckCall(e.getMessage(), clientIp);
}
DRNatCheckResponse resp = new DRNatCheckResponse();
resp.setSeenIp(clientIp);
resp.setBehindNAT(isBehindNat);
return resp;
}
Aggregations