Commit 2d3fa249 authored by pgouvas's avatar pgouvas
Browse files

Altered Service Layer

parent da75bab4
......@@ -2,15 +2,21 @@ package eu.ubitech.ejbca.rest;
import eu.ubitech.ejbca.client.EjbcaUser;
import eu.ubitech.ejbca.client.EjbcaWSClientImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import org.ejbca.core.protocol.ws.AuthorizationDeniedException_Exception;
import org.ejbca.core.protocol.ws.Certificate;
import org.ejbca.core.protocol.ws.EjbcaException_Exception;
import org.ejbca.core.protocol.ws.NameAndId;
import org.ejbca.core.protocol.ws.RevokeStatus;
import org.ejbca.core.protocol.ws.UserDataVOWS;
import org.ejbca.core.protocol.ws.UserMatch;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
......@@ -38,40 +44,55 @@ public class RestCAController {
return availableCAs;
}//EoM
@RequestMapping(path = "/1", method = RequestMethod.GET)
public void test1(HttpServletRequest request) {
List<Certificate> certs = ca.getCACert("ManagementCA");
@RequestMapping(path = "/getCACertificates/{caname}", method = RequestMethod.GET)
public List<Certificate> getCACertificates(@PathVariable("caname") String caname) {
List<Certificate> certs = ca.getCACert(caname);
logger.info("Existing CAs: "+certs.size());
// certs.forEach(cert->{logger.info(new String(cert.getCertificateData()));});
certs.forEach(cert->{logger.info(new String(cert.getCertificateData()));});
return certs;
}//EoM
@RequestMapping(path = "/getEntityprofiles", method = RequestMethod.GET)
public List<NameAndId> getEntityprofiles() {
List<NameAndId> profiles = new ArrayList<>();
try {
profiles = ca.getEjbcaRAWS().getAuthorizedEndEntityProfiles();
} catch (AuthorizationDeniedException_Exception | EjbcaException_Exception ex) {
Logger.getLogger(RestCAController.class.getName()).log(Level.SEVERE, null, ex);
}
logger.info("getEntityprofiles: "+profiles.size());
profiles.forEach(profile->{logger.info(profile.getName());});
return profiles;
}//EoM
@RequestMapping(path = "/getCertificateprofiles/{entityprofileid}", method = RequestMethod.GET)
public List<NameAndId> getCertificateprofiles(@PathVariable("entityprofileid") int entityprofileid) {
List<NameAndId> certprofiles = new ArrayList<>();
try {
certprofiles = ca.getEjbcaRAWS().getAvailableCertificateProfiles(entityprofileid);
} catch (AuthorizationDeniedException_Exception | EjbcaException_Exception ex) {
Logger.getLogger(RestCAController.class.getName()).log(Level.SEVERE, null, ex);
}
logger.info("getCertificateprofiles: "+certprofiles.size());
certprofiles.forEach(profile->{logger.info(profile.getName());});
return certprofiles;
}//EoM
@RequestMapping(path = "/manageEntity", method = RequestMethod.POST)
public Boolean createEntity(@RequestBody EjbcaUser ejbcaUser) {
boolean status = ca.editUser(ejbcaUser);
logger.info("manageEntity: "+status);
return status;
}//EoM
@RequestMapping(path = "/2", method = RequestMethod.GET)
public void test2(HttpServletRequest request) {
RevokeStatus revokestatus = ca.checkCertificateRevokeStatus("CN=ManagementCA", "-628002118");
logger.info("RevokeStatus: "+revokestatus);
}//EoM
@RequestMapping(path = "/3", method = RequestMethod.GET)
public void test3(HttpServletRequest request) {
String username = "user1";
String password = "pass1";
String dn = "CN=RO1"; //
String caname = "ManagementCA";
String eeprofilename = "DOCTORS";
String cerprofilename = "ENDUSER";
//------------
EjbcaUser ejbcaUser = new EjbcaUser();
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.USERNAME, username);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.PASSWORD, password);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.CA, caname);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.SUBJECTDN, dn);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.ENDENTITYPROFILE, eeprofilename);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.CERTIFICATEPROFILE, cerprofilename);
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.EMAIL, "pgouvas@gmail.com");
ejbcaUser.setEntityArgument(EjbcaUser.Arguments.TOKEN, "P12");
boolean status = ca.editUser(ejbcaUser);
logger.info("Add user: "+status);
}//EoM
@RequestMapping(path = "/4", method = RequestMethod.GET)
public void test4(HttpServletRequest request) {
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.557+02:00
* 2020-01-06T16:42:37.084+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.525+02:00
* 2020-01-06T16:42:37.052+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.487+02:00
* 2020-01-06T16:42:37.006+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.463+02:00
* 2020-01-06T16:42:36.970+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.480+02:00
* 2020-01-06T16:42:36.996+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.472+02:00
* 2020-01-06T16:42:36.986+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.613+02:00
* 2020-01-06T16:42:37.160+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.600+02:00
* 2020-01-06T16:42:37.142+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.591+02:00
* 2020-01-06T16:42:37.129+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.609+02:00
* 2020-01-06T16:42:37.155+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.518+02:00
* 2020-01-06T16:42:37.044+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.604+02:00
* 2020-01-06T16:42:37.148+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.570+02:00
* 2020-01-06T16:42:37.102+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.494+02:00
* 2020-01-06T16:42:37.019+02:00
* Generated source version: 3.3.2
*/
......
......@@ -10,7 +10,7 @@ import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.617+02:00
* 2020-01-06T16:42:37.167+02:00
* Generated source version: 3.3.2
*
*/
......
......@@ -10,7 +10,7 @@ import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.650+02:00
* 2020-01-06T16:42:37.214+02:00
* Generated source version: 3.3.2
*
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.532+02:00
* 2020-01-06T16:42:37.058+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.454+02:00
* 2020-01-06T16:42:36.956+02:00
* Generated source version: 3.3.2
*/
......
......@@ -6,7 +6,7 @@ import javax.xml.ws.WebFault;
/**
* This class was generated by Apache CXF 3.3.2
* 2020-01-06T12:47:16.544+02:00
* 2020-01-06T16:42:37.071+02:00
* Generated source version: 3.3.2
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment