@Test public void Test10GetKey() throws Exception { Mockito.when(restErrorUtil.createRESTException(Mockito.nullable(String.class), (MessageEnums) Mockito.any())) .thenReturn(new WebApplicationException()); thrown.expect(WebApplicationException.class); VXKmsKey vxKeyAct = keyREST.getKey(nameNl, provider); Assert.assertNull(vxKeyAct); Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()); }
@GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") public VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider){ VXKmsKey vxKmsKey = new VXKmsKey(); try{ if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } vxKmsKey = keyMgr.getKey(provider, name); }catch(Exception e){ handleError(e); } return vxKmsKey; }
XKeyREST { @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") public VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider){ VXKmsKey vxKmsKey = new VXKmsKey(); try{ if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } vxKmsKey = keyMgr.getKey(provider, name); }catch(Exception e){ handleError(e); } return vxKmsKey; } }
XKeyREST { @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") public VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider){ VXKmsKey vxKmsKey = new VXKmsKey(); try{ if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } vxKmsKey = keyMgr.getKey(provider, name); }catch(Exception e){ handleError(e); } return vxKmsKey; }  }
XKeyREST { @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") public VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider){ VXKmsKey vxKmsKey = new VXKmsKey(); try{ if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } vxKmsKey = keyMgr.getKey(provider, name); }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 { @GET @Path("/key/{alias}") @Produces({ "application/xml", "application/json" }) @PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_KEY + "\")") public VXKmsKey getKey(@PathParam("alias") String name,@QueryParam("provider") String provider){ VXKmsKey vxKmsKey = new VXKmsKey(); try{ if (name == null || name.isEmpty()) { throw restErrorUtil.createRESTException("Please provide a valid " + "alias.", MessageEnums.INVALID_INPUT_DATA); } vxKmsKey = keyMgr.getKey(provider, name); }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);  }