static void writeQueryResponseChunk(Object queryResponseChunk, CollectionType collectionType, boolean lastChunk, ServerConnection serverConnection) throws IOException { ChunkedMessage queryResponseMsg = serverConnection.getQueryResponseMessage(); queryResponseMsg.setNumberOfParts(2); queryResponseMsg.setLastChunk(lastChunk); queryResponseMsg.addObjPart(collectionType, false); queryResponseMsg.addObjPart(queryResponseChunk, false); queryResponseMsg.sendChunk(serverConnection); }
protected void writeFunctionExceptionResponse(ChunkedMessage message, String errormessage, Throwable e) throws IOException { if (logger.isDebugEnabled()) { logger.debug("ServerToClientFunctionResultSender sending Function Error Response: {}", errormessage); } message.clear(); message.setLastChunk(true); message.addObjPart(e); message.sendChunk(this.sc); this.sc.setAsTrue(Command.RESPONDED); }
private void sendDurableCqsResponseChunk(List list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} durableCQs response chunk{}", servConn.getName(), lastChunk ? " last " : " ", logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : ""); } chunkedResponseMsg.sendChunk(servConn); }
private static void sendGetAllResponseChunk(Region region, ObjectPartList list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} getAll response chunk for region={} values={} chunk=<{}>", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), list, chunkedResponseMsg); } chunkedResponseMsg.sendChunk(servConn); }
private static void sendGetAllResponseChunk(Region region, ObjectPartList651 list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} getAll response chunk for region={} values={} chunk=<{}>", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), list, chunkedResponseMsg); } chunkedResponseMsg.sendChunk(servConn); }
public static void sendNewRegisterInterestResponseChunk(LocalRegion region, Object riKey, VersionedObjectList list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getRegisterInterestResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); String regionName = region == null ? " null " : region.getFullPath(); if (logger.isDebugEnabled()) { logger.debug( "{}: Sending{}register interest response chunk for region: {} for keys: {} chunk=<{}>", servConn.getName(), lastChunk ? " last " : " ", regionName, riKey, chunkedResponseMsg); } chunkedResponseMsg.sendChunk(servConn); }
private static void sendKeySetResponseChunk(Region region, List list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} key set response chunk for region={}{}", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), (logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : "")); } chunkedResponseMsg.sendChunk(servConn); }
/** * @param list is a List of entry keys */ private static void sendRegisterInterestResponseChunk(Region region, Object riKey, List list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getRegisterInterestResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); String regionName = region == null ? " null " : region.getFullPath(); if (logger.isDebugEnabled()) { logger.debug( "{}: Sending{}register interest response chunk for region: {} for keys: {} chunk=<{}>", servConn.getName(), lastChunk ? " last " : " ", regionName, riKey, chunkedResponseMsg); } chunkedResponseMsg.sendChunk(servConn); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); this.registerInterest.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestListAuthorize(eq(REGION_NAME), any(), any()); this.registerInterestList.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestListAuthorize(eq(REGION_NAME), any(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .keySetAuthorize(eq(REGION_NAME)); this.keySet.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).keySetAuthorize(eq(REGION_NAME)); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestListAuthorize(eq(REGION_NAME), any(), any()); this.registerInterestList66.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestListAuthorize(eq(REGION_NAME), any(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); } }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestListAuthorize(eq(REGION_NAME), any(), any()); this.registerInterestList61.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestListAuthorize(eq(REGION_NAME), any(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); doThrow(new NotAuthorizedException("")).when(this.authzRequest) .registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); this.registerInterest61.cmdExecute(this.message, this.serverConnection, this.securityService, 0); verify(this.authzRequest).registerInterestAuthorize(eq(REGION_NAME), eq(KEY), anyInt(), any()); ArgumentCaptor<NotAuthorizedException> argument = ArgumentCaptor.forClass(NotAuthorizedException.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture()); assertThat(argument.getValue()).isExactlyInstanceOf(NotAuthorizedException.class); verify(this.chunkedResponseMessage).sendChunk(this.serverConnection); }
@Test public void integratedSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void integratedSecurityShouldSucceedIfAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(true); this.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object key : argument.getValue().getKeys()) { assertThat(key).isIn(KEYS); } for (Object key : KEYS) { verify(this.securityService).authorize(Resource.DATA, Operation.READ, REGION_NAME, key.toString()); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); for (Object key : KEYS) { doThrow(new NotAuthorizedException("")).when(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } this.getAll.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }
@Test public void oldSecurityShouldFailIfNotAuthorized() throws Exception { when(this.securityService.isClientSecurityRequired()).thenReturn(true); when(this.securityService.isIntegratedSecurity()).thenReturn(false); for (Object key : KEYS) { doThrow(new NotAuthorizedException("")).when(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } this.getAll651.cmdExecute(this.message, this.serverConnection, this.securityService, 0); ArgumentCaptor<ObjectPartList> argument = ArgumentCaptor.forClass(ObjectPartList.class); verify(this.chunkedResponseMessage).addObjPart(argument.capture(), eq(false)); assertThat(argument.getValue().getObjects()).hasSize(KEYS.length); for (Object o : argument.getValue().getObjects()) { assertThat(o).isExactlyInstanceOf(NotAuthorizedException.class); } for (Object key : KEYS) { verify(this.authzRequest).getAuthorize(eq(REGION_NAME), eq(key.toString()), eq(null)); } verify(this.chunkedResponseMessage).sendChunk(eq(this.serverConnection)); }