@Test public void Test8CreateKey() throws Exception { VXKmsKey vxKeyExp = new VXKmsKey(); Mockito.when(restErrorUtil.createRESTException(Mockito.nullable(String.class), (MessageEnums) Mockito.any())) .thenReturn(new WebApplicationException()); thrown.expect(WebApplicationException.class); VXKmsKey vxKeyAct = keyREST.createKey(provider, vxKeyExp); Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()); Assert.assertNull(vxKeyAct); }
@POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") public VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey) { VXKmsKey vxKmsKey = new VXKmsKey(); try{ String name = vXKey.getName(); if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } if(vXKey.getCipher() == null || vXKey.getCipher().trim().isEmpty()){ vXKey.setCipher(null); } vxKmsKey = keyMgr.createKey(provider, vXKey); }catch(Exception e){ handleError(e); } return vxKmsKey; }
XKeyREST { @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") public VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey) { VXKmsKey vxKmsKey = new VXKmsKey(); try{ String name = vXKey.getName(); if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } if(vXKey.getCipher() == null || vXKey.getCipher().trim().isEmpty()){ vXKey.setCipher(null); } vxKmsKey = keyMgr.createKey(provider, vXKey); }catch(Exception e){ handleError(e); } return vxKmsKey; } }
XKeyREST { @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") public VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey) { VXKmsKey vxKmsKey = new VXKmsKey(); try{ String name = vXKey.getName(); if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } if(vXKey.getCipher() == null || vXKey.getCipher().trim().isEmpty()){ vXKey.setCipher(null); } vxKmsKey = keyMgr.createKey(provider, vXKey); }catch(Exception e){ handleError(e); } return vxKmsKey; }  }
XKeyREST { @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") public VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey) { VXKmsKey vxKmsKey = new VXKmsKey(); try{ String name = vXKey.getName(); if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } if(vXKey.getCipher() == null || vXKey.getCipher().trim().isEmpty()){ vXKey.setCipher(null); } vxKmsKey = keyMgr.createKey(provider, vXKey); }catch(Exception e){ handleError(e); } return vxKmsKey; }  @GET @Path("/keys") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_KEYS + "\")") VXKmsKeyList searchKeys(@Context HttpServletRequest request, @QueryParam("provider") String provider); @PUT @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.ROLLOVER_KEYS + "\")") VXKmsKey rolloverKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @DELETE @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_KEY + "\")") void deleteKey(@PathParam("alias") String name, @QueryParam("provider") String provider, @Context HttpServletRequest request); @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider); }
XKeyREST { @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") public VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey) { VXKmsKey vxKmsKey = new VXKmsKey(); try{ String name = vXKey.getName(); if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } if(vXKey.getCipher() == null || vXKey.getCipher().trim().isEmpty()){ vXKey.setCipher(null); } vxKmsKey = keyMgr.createKey(provider, vXKey); }catch(Exception e){ handleError(e); } return vxKmsKey; }  @GET @Path("/keys") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_KEYS + "\")") VXKmsKeyList searchKeys(@Context HttpServletRequest request, @QueryParam("provider") String provider); @PUT @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.ROLLOVER_KEYS + "\")") VXKmsKey rolloverKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @DELETE @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.DELETE_KEY + "\")") void deleteKey(@PathParam("alias") String name, @QueryParam("provider") String provider, @Context HttpServletRequest request); @POST @Path("/key") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.CREATE_KEY + "\")") VXKmsKey createKey(@QueryParam("provider") String provider, VXKmsKey vXKey); @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider);  }