Skip to content

Commit

Permalink
change get ipaddress code
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenwinship committed Oct 9, 2024
1 parent 6090fb5 commit be2c143
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.io.IOException;

import edu.harvard.iq.dataverse.authorization.groups.impl.ipaddress.ip.IpAddress;
import edu.harvard.iq.dataverse.engine.command.DataverseRequest;
import jakarta.inject.Inject;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -31,13 +31,7 @@ public void init() throws ServletException {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String ipAddress = req.getHeader("X-FORWARDED-FOR");
if (ipAddress == null) {
ipAddress = req.getRemoteAddr();
}
if (ipAddress != null) {
serviceDocumentManagerImpl.setIpAddress(IpAddress.valueOf(ipAddress));
}
serviceDocumentManagerImpl.setIpAddress((new DataverseRequest(null, req)).getSourceAddress());
this.api.get(req, resp);
}

Expand Down

0 comments on commit be2c143

Please sign in to comment.