@Override public Object attempt(Connection cnx) throws Exception { if (cnx.getServer().getRequiresCredentials()) { return super.attempt(cnx); } else { return null; } }
/** * 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()); } }
private void authenticateIfRequired(Connection conn) { cancelCriterion.checkCancelInProgress(null); if (!pool.isUsedByGateway() && !pool.getMultiuserAuthentication()) { ServerLocation server = conn.getServer(); if (server.getRequiresCredentials()) { if (server.getUserId() == -1) { Long uniqueID = (Long) AuthenticateUserOp.executeOn(conn, pool); server.setUserId(uniqueID); if (logger.isDebugEnabled()) { logger.debug("CFI.authenticateIfRequired() Completed authentication on {}", conn); } } } } }
@Test(expected = CancelException.class) public void connectionFactoryThrowsCancelException() throws CancelException, IOException { ServerLocation serverLocation = mock(ServerLocation.class); doReturn(false).when(serverLocation).getRequiresCredentials();
private void authenticateIfRequired(Connection conn, Op op) { if (!conn.getServer().getRequiresCredentials()) { return;
if (cnx.getServer().getRequiresCredentials()) {