Search in sources :

Example 1 with ExcludeLicenseCheck

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;
}
Also used : DRNatCheckResponse(com.emc.storageos.model.dr.DRNatCheckResponse) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException) Path(javax.ws.rs.Path) ZkPath(com.emc.storageos.coordinator.common.impl.ZkPath) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ExcludeLicenseCheck(com.emc.storageos.security.authorization.ExcludeLicenseCheck) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 DRNatCheckResponse (com.emc.storageos.model.dr.DRNatCheckResponse)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ExcludeLicenseCheck (com.emc.storageos.security.authorization.ExcludeLicenseCheck)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 UnknownHostException (java.net.UnknownHostException)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1