@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("type=").append(MessageType.getString(this.messageType)); sb.append("; payloadLength=").append(this.payloadLength); sb.append("; numberOfParts=").append(this.numberOfParts); sb.append("; hasSecurePart=").append(isSecureMode()); sb.append("; transactionId=").append(this.transactionId); sb.append("; currentPart=").append(this.currentPart); sb.append("; messageModified=").append(this.messageModified); sb.append("; flags=").append(Integer.toHexString(this.flags)); for (int i = 0; i < this.numberOfParts; i++) { sb.append("; part[").append(i).append("]={"); sb.append(this.partsList[i]); sb.append("}"); } return sb.toString(); }
public void removeCq(String cqName, boolean isDurable) { final boolean isDebugEnabled = logger.isDebugEnabled(); if (this.requestMessage.isSecureMode()) { if (isDebugEnabled) { logger.debug("removeCq() security header found registering CQname = {}", cqName); } try { this.clientUserAuths.removeUserAuthAttributesForCq(cqName, isDurable); } catch (Exception ex) { if (isDebugEnabled) { logger.debug("While setting cq got exception ", ex); } } } else { if (isDebugEnabled) { logger.debug("removeCq() security header is not found"); } } }
/** * Process the security information in a response from the server. If the server sends a security * "part" we must process it so all subclasses should allow this method to be invoked. * * @see ServerConnection#updateAndGetSecurityPart() */ protected void processSecureBytes(Connection cnx, Message message) throws Exception { if (cnx.getServer().getRequiresCredentials()) { if (!message.isSecureMode()) { // This can be seen during shutdown if (logger.isTraceEnabled(LogMarker.BRIDGE_SERVER_VERBOSE)) { logger.trace(LogMarker.BRIDGE_SERVER_VERBOSE, "Response message from {} for {} has no secure part.", cnx, this); } return; } byte[] partBytes = message.getSecureBytes(); if (partBytes == null) { if (logger.isDebugEnabled()) { logger.debug("Response message for {} has no bytes in secure part.", this); } return; } byte[] bytes = ((ConnectionImpl) cnx).decryptBytes(partBytes); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(bytes)); cnx.setConnectionID(dis.readLong()); } }
@Test public void post65NonSecureShouldThrow() { when(handshake.getVersion()).thenReturn(Version.GFE_82); when(requestMsg.isSecureMode()).thenReturn(false); assertThatThrownBy(serverConnection::getUniqueId) .isExactlyInstanceOf(AuthenticationRequiredException.class) .hasMessage("No security credentials are provided"); } }
@Test public void pre65SecureShouldReturnUserAuthId() { long userAuthId = 12345L; serverConnection.setUserAuthId(userAuthId); when(handshake.getVersion()).thenReturn(Version.GFE_61); when(requestMsg.isSecureMode()).thenReturn(true); assertThat(serverConnection.getUniqueId()).isEqualTo(userAuthId); }
@Test public void pre65NonSecureShouldReturnUserAuthId() { long userAuthId = 12345L; serverConnection.setUserAuthId(userAuthId); when(handshake.getVersion()).thenReturn(Version.GFE_61); when(requestMsg.isSecureMode()).thenReturn(false); assertThat(serverConnection.getUniqueId()).isEqualTo(userAuthId); }
@Test public void post65SecureShouldUseUniqueIdFromMessage() { long uniqueIdFromMessage = 23456L; when(handshake.getVersion()).thenReturn(Version.GFE_82); serverConnection.setRequestMessage(requestMsg); assertThat(serverConnection.getRequestMessage()).isSameAs(requestMsg); when(requestMsg.isSecureMode()).thenReturn(true); when(messageIdExtractor.getUniqueIdFromMessage(any(Message.class), any(Encryptor.class), anyLong())).thenReturn(uniqueIdFromMessage); serverConnection.setMessageIdExtractor(messageIdExtractor); assertThat(serverConnection.getUniqueId()).isEqualTo(uniqueIdFromMessage); }
public void setCq(String cqName, boolean isDurable) throws Exception { final boolean isDebugEnabled = logger.isDebugEnabled(); if (this.requestMessage.isSecureMode()) { if (isDebugEnabled) { logger.debug("setCq() security header found registering CQname = {}", cqName); } try { byte[] secureBytes = this.requestMessage.getSecureBytes(); secureBytes = this.handshake.getEncryptor().decryptBytes(secureBytes); AuthIds aIds = new AuthIds(secureBytes); long uniqueId = aIds.getUniqueId(); CacheClientProxy proxy = getAcceptor().getCacheClientNotifier().getClientProxy(this.proxyId); if (proxy != null) { proxy.setCQVsUserAuth(cqName, uniqueId, isDurable); } } catch (Exception ex) { if (isDebugEnabled) { logger.debug("While setting cq got exception ", ex); } throw ex; } } else { if (isDebugEnabled) { logger.debug("setCq() security header is not found "); } } }
public long getUniqueId() { long uniqueId; if (this.handshake.getVersion().isPre65() || communicationMode.isWAN()) { uniqueId = this.userAuthId; } else if (this.requestMessage.isSecureMode()) { uniqueId = messageIdExtractor.getUniqueIdFromMessage(this.requestMessage, this.handshake.getEncryptor(), this.connectionId); } else { throw new AuthenticationRequiredException( "No security credentials are provided"); } return uniqueId; }
if (!AcceptorImpl.isAuthenticationRequired() && message.isSecureMode()) { if (!message.isSecureMode()) { throw new AuthenticationFailedException("Authentication failed");
final SecurityService securityService, long start) throws IOException, ClassNotFoundException, InterruptedException { boolean isSecureMode = clientMessage.isSecureMode();
final SecurityService securityService, long start) throws IOException, ClassNotFoundException, InterruptedException { boolean isSecureMode = clientMessage.isSecureMode();