Skip to content

Commit bca8499

Browse files
committed
Move or delete resteasy dependency
Remove the use of MultivaluedMap and UriInfo because they were not actually used outside of v1 APIs. Replace Response status with HttpStatus in the check and resteasy MediaType with internal MimeType. Finally some static values have been duplicated outside of Resource classes.
1 parent 12c3966 commit bca8499

23 files changed

Lines changed: 71 additions & 117 deletions

File tree

base/ca/src/main/java/com/netscape/cms/servlet/cert/CertReviewResponseFactory.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import java.util.Locale;
2222

2323
import javax.servlet.http.HttpServletRequest;
24-
import javax.ws.rs.core.UriInfo;
25-
2624
import com.netscape.certsrv.base.EBaseException;
2725
import com.netscape.certsrv.cert.CertReviewResponse;
2826
import com.netscape.certsrv.profile.EProfileException;
@@ -45,7 +43,7 @@ public class CertReviewResponseFactory {
4543

4644
public static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(CertReviewResponseFactory.class);
4745

48-
public static CertReviewResponse create(Request request, Profile profile, UriInfo uriInfo, Locale locale) throws EBaseException {
46+
public static CertReviewResponse create(Request request, Profile profile, Locale locale) throws EBaseException {
4947
CertReviewResponse ret = new CertReviewResponse();
5048

5149
if (request.getRequestType().equals("renewal")) {

base/ca/src/main/java/org/dogtagpki/server/ca/rest/v1/CertRequestDAO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public CertReviewResponse reviewRequest(HttpServletRequest servletRequest, Reque
165165

166166
CAEngine engine = CAEngine.getInstance();
167167
Profile profile = ps.getProfile(profileId);
168-
CertReviewResponse info = CertReviewResponseFactory.create(request, profile, uriInfo, locale);
168+
CertReviewResponse info = CertReviewResponseFactory.create(request, profile, locale);
169169

170170
if (engine.getEnableNonces()) {
171171
// generate nonce

base/ca/src/main/java/org/dogtagpki/server/ca/rest/v2/AgentCertRequestServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private CertReviewResponse getRequestData(HttpServletRequest servletRequest, Req
221221
String profileId = request.getExtDataInString(Request.PROFILE_ID);
222222

223223
Profile profile = ps.getProfile(profileId);
224-
info = CertReviewResponseFactory.create(request, profile, null, servletRequest.getLocale());
224+
info = CertReviewResponseFactory.create(request, profile, servletRequest.getLocale());
225225

226226
if (random != null) {
227227
// generate nonce

base/common/src/main/java/com/netscape/certsrv/cert/CertEnrollmentRequest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Collection;
2828
import java.util.HashMap;
2929

30-
import javax.ws.rs.core.MultivaluedMap;
3130
import javax.xml.XMLConstants;
3231
import javax.xml.parsers.DocumentBuilder;
3332
import javax.xml.parsers.DocumentBuilderFactory;
@@ -94,15 +93,6 @@ public class CertEnrollmentRequest extends RESTMessage {
9493
public CertEnrollmentRequest() {
9594
}
9695

97-
public CertEnrollmentRequest(MultivaluedMap<String, String> form) {
98-
profileId = form.getFirst(PROFILE_ID);
99-
String renewalStr = form.getFirst(RENEWAL);
100-
serialNum = new CertId(form.getFirst(SERIAL_NUM));
101-
renewal = Boolean.valueOf(renewalStr);
102-
103-
serverSideKeygenP12Passwd = form.getFirst(SERVERSIDE_KEYGEN_P12_PASSWD);
104-
}
105-
10696
/**
10797
* @return the profileId
10898
*/

base/common/src/main/java/com/netscape/certsrv/key/AsymKeyGenerationRequest.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Arrays;
2323
import java.util.List;
2424

25-
import javax.ws.rs.core.MultivaluedMap;
2625
import javax.xml.parsers.DocumentBuilder;
2726
import javax.xml.parsers.DocumentBuilderFactory;
2827

@@ -55,21 +54,6 @@ public AsymKeyGenerationRequest() {
5554
setClassName(getClass().getName());
5655
}
5756

58-
public AsymKeyGenerationRequest(MultivaluedMap<String, String> form) {
59-
attributes.put(CLIENT_KEY_ID, form.getFirst(CLIENT_KEY_ID));
60-
attributes.put(KEY_SIZE, form.getFirst(KEY_SIZE));
61-
attributes.put(KEY_ALGORITHM, form.getFirst(KEY_ALGORITHM));
62-
attributes.put(KEY_USAGE, form.getFirst(KEY_USAGE));
63-
attributes.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY));
64-
attributes.put(REALM, form.getFirst(REALM));
65-
66-
String usageString = attributes.get(KEY_USAGE);
67-
if (!StringUtils.isBlank(usageString)) {
68-
setUsages(new ArrayList<>(Arrays.asList(usageString.split(","))));
69-
}
70-
setClassName(getClass().getName());
71-
}
72-
7357
public AsymKeyGenerationRequest(RESTMessage data) {
7458
attributes.putAll(data.getAttributes());
7559
setClassName(getClass().getName());

base/common/src/main/java/com/netscape/certsrv/key/KeyRecoveryRequest.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
import java.util.Map;
2525

26-
import javax.ws.rs.core.MultivaluedMap;
27-
2826
import com.fasterxml.jackson.annotation.JsonIgnore;
2927
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3028
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -55,21 +53,6 @@ public KeyRecoveryRequest() {
5553
setClassName(getClass().getName());
5654
}
5755

58-
public KeyRecoveryRequest(MultivaluedMap<String, String> form) {
59-
if (form.containsKey(KEY_ID)) {
60-
attributes.put(KEY_ID, form.getFirst(KEY_ID));
61-
}
62-
if (form.containsKey(REQUEST_ID)) {
63-
attributes.put(REQUEST_ID, form.getFirst(REQUEST_ID));
64-
}
65-
attributes.put(TRANS_WRAPPED_SESSION_KEY, form.getFirst(TRANS_WRAPPED_SESSION_KEY));
66-
attributes.put(SESSION_WRAPPED_PASSPHRASE, form.getFirst(SESSION_WRAPPED_PASSPHRASE));
67-
attributes.put(NONCE_DATA, form.getFirst(NONCE_DATA));
68-
attributes.put(CERTIFICATE, form.getFirst(CERTIFICATE));
69-
attributes.put(PASSPHRASE, form.getFirst(PASSPHRASE));
70-
setClassName(getClass().getName());
71-
}
72-
7356
public KeyRecoveryRequest(RESTMessage data) {
7457
attributes.putAll(data.getAttributes());
7558
setClassName(getClass().getName());

base/common/src/main/java/com/netscape/certsrv/system/KRAConnectorInfo.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
// --- END COPYRIGHT BLOCK ---
1818
package com.netscape.certsrv.system;
1919

20-
import javax.ws.rs.core.MultivaluedMap;
21-
2220
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2321
import com.fasterxml.jackson.annotation.JsonInclude;
2422
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@@ -54,18 +52,6 @@ public class KRAConnectorInfo implements JSONSerializer {
5452
public KRAConnectorInfo() {
5553
}
5654

57-
public KRAConnectorInfo(MultivaluedMap<String, String> form) {
58-
host = form.getFirst(HOST);
59-
port = form.getFirst(PORT);
60-
subsystemCert = form.getFirst(SUBSYSTEM_CERT);
61-
transportCert = form.getFirst(TRANSPORT_CERT);
62-
uri = form.getFirst(URI);
63-
timeout = form.getFirst(TIMEOUT);
64-
local = form.getFirst(LOCAL);
65-
enable = form.getFirst(ENABLE);
66-
transportCertNickname = form.getFirst(TRANSPORT_CERT_NICKNAME);
67-
}
68-
6955
public String getHost() {
7056
return host;
7157
}

base/common/src/main/java/org/dogtagpki/ca/CASystemCertClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.io.ByteArrayInputStream;
2121
import java.security.cert.X509Certificate;
2222

23-
import javax.ws.rs.core.Response;
23+
import org.apache.http.HttpStatus;
2424

2525
import org.mozilla.jss.netscape.security.pkcs.ContentInfo;
2626
import org.mozilla.jss.netscape.security.pkcs.PKCS7;
@@ -57,7 +57,7 @@ public CertData getSigningCert() throws Exception {
5757
certData = get("signing", CertData.class);
5858

5959
} catch (PKIException e) {
60-
if (e.getCode() != Response.Status.NOT_FOUND.getStatusCode()) {
60+
if (e.getCode() != HttpStatus.SC_NOT_FOUND) {
6161
throw e;
6262
}
6363
logger.warn("Unable to get CA signing certificate: " + e.getMessage());

base/common/src/main/java/org/dogtagpki/common/CAInfoClient.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* @author Ade Lee
2929
*/
3030
public class CAInfoClient extends Client {
31+
public static final String KEYWRAP_MECHANISM = "keywrap";
3132

3233
public CAInfoClient(PKIClient client, String subsystem) throws Exception {
3334
super(client, subsystem, "v2", "info");
@@ -39,7 +40,7 @@ public CAInfo getInfo() throws Exception {
3940

4041
public String getKeyWrapAlgotihm() throws Exception {
4142

42-
String archivalMechanism = KRAInfoResource.KEYWRAP_MECHANISM;
43+
String archivalMechanism = KEYWRAP_MECHANISM;
4344
String kwAlg = null;
4445

4546
try {
@@ -50,7 +51,7 @@ public String getKeyWrapAlgotihm() throws Exception {
5051
} catch (PKIException e) {
5152
if (e.getCode() == 404) {
5253
// assume this is an older server
53-
archivalMechanism = KRAInfoResource.KEYWRAP_MECHANISM;
54+
archivalMechanism = KEYWRAP_MECHANISM;
5455
kwAlg = KeyWrapAlgorithm.DES3_CBC_PAD.toString();
5556

5657
} else {
@@ -61,7 +62,7 @@ public String getKeyWrapAlgotihm() throws Exception {
6162
throw new Exception("Failed to retrieve archive wrapping information from the CA: " + e, e);
6263
}
6364

64-
if (!archivalMechanism.equals(KRAInfoResource.KEYWRAP_MECHANISM)) {
65+
if (!archivalMechanism.equals(KEYWRAP_MECHANISM)) {
6566
// new server with encryption set. Use something we know will
6667
// work. AES-128-CBC
6768
kwAlg = KeyWrapAlgorithm.AES_CBC_PAD.toString();

base/common/src/main/java/org/dogtagpki/common/ConfigClient.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
*/
4444
public class ConfigClient extends Client {
4545

46-
public final static Logger logger = LoggerFactory.getLogger(ConfigClient.class);
46+
public static final String SUCCESS = "0";
47+
public static final String FAILURE = "1";
48+
public static final String AUTH_FAILURE = "2";
49+
public static final Logger logger = LoggerFactory.getLogger(ConfigClient.class);
4750

4851
public ConfigClient(PKIClient client, String subsystem) throws Exception {
4952
super(client, subsystem, "config");
@@ -84,11 +87,11 @@ public ConfigData getConfig(
8487
String status = parser.getValue("Status");
8588
logger.debug("Status: " + status);
8689

87-
if (status.equals(ConfigResource.AUTH_FAILURE)) {
90+
if (AUTH_FAILURE.equals(status)) {
8891
throw new EAuthException("Authentication failed");
8992
}
9093

91-
if (!status.equals(ConfigResource.SUCCESS)) {
94+
if (!SUCCESS.equals(status)) {
9295
String error = parser.getValue("Error");
9396
throw new IOException(error);
9497
}

0 commit comments

Comments
 (0)