javax.naming.SizeLimitExceededException Java Examples
The following examples show how to use
javax.naming.SizeLimitExceededException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataProvider.java From minecraft-world-downloader with GNU General Public License v3.0 | 6 votes |
/** * Provides the object with all the bytes from the packet, allowing them to be read into the correct data types * easily. This method will also decompress the packet, as this is the first time we have the full packet * available, which is what we need for valid decompression. * @param size the packet size * @return the data parser for the decompressed packet */ public DataTypeProvider withSize(int size) throws SizeLimitExceededException { byte[] compressed = reader.readByteArray(size); byte[] fullPacket; if (compressionManager.isCompressionEnabled()) { final int[] compressionPos = {0}; int uncompressedSize = DataReader.readVarInt( () -> compressionPos[0] < compressed.length, () -> compressed[compressionPos[0]++] ); // packets over this size will crash the game client, so it may help to reject them here if (uncompressedSize > MAX_SIZE) { throw new SizeLimitExceededException("WARNING: discarding packet over maximum size (size: " + uncompressedSize + ")"); } fullPacket = compressionManager.decompressPacket(compressed, compressionPos[0], uncompressedSize); } else { fullPacket = compressed; } return DataTypeProvider.ofPacket(fullPacket); }
Example #2
Source File: PacketBuilder.java From minecraft-world-downloader with GNU General Public License v3.0 | 6 votes |
/** * Build the given packet, will generate a type provider to parse the contents of the packages to real values. Will * determine if the packet is to be forwarded using its return value. * @param size the size of the packet to build * @return true if the packet should be forwarded, otherwise false. */ public final boolean build(int size) { DataTypeProvider typeProvider; try { typeProvider = reader.withSize(size); } catch (SizeLimitExceededException ex) { System.out.println(ex.getMessage()); return false; } int packetID = typeProvider.readVarInt(); String packetType = protocol.get(packetID, isClientBound()); PacketOperator operator = getOperators().getOrDefault(packetType, null); if (operator == null) { return true; } return operator.apply(typeProvider); }
Example #3
Source File: RPCMethods.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * * @param portID the port ID * @param force if force is set to true then the port will be acquired even * though it is owned by other * @return connectionHandler in case of success * @throws PortAcquireException */ public String acquireServerPort(int portID, boolean force) throws PortAcquireException { LOG.trace("Acquiring port [" + portID + "]"); LogsController.getInstance().appendText(LogType.INFO, "Acquiring port [" + portID + "]"); AcquireParams acquireParams = new AcquireParams(); acquireParams.setPortId(portID); acquireParams.setForce(force); acquireParams.setUser(serverConnectionManager.getClientName()); acquireParams.setSessionId(Util.getRandomID()); ObjectMapper mapper = new ObjectMapper(); try { String response = serverConnectionManager.sendRPCRequest(Constants.ACQUIRE_METHOD, acquireParams); response = Util.removeFirstBrackets(response); RPCResponse rpcResult = mapper.readValue(response, RPCResponse.class); String handler = mapper.readValue(rpcResult.getResult(), String.class); connectionHandler.put(portID, handler); serverConnectionManager.propagatePortHandler(portID, handler); return handler; } catch (InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | IOException | SizeLimitExceededException ex) { throw new PortAcquireException(ex.getMessage()); } }
Example #4
Source File: RPCMethods.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * * @param portID * @param force * @param type * @param multiplierValue * @return multiplier value from the server * @throws com.exalttech.trex.remote.exceptions.TrafficException */ public double updateTraffic(int portID, boolean force, String type, double multiplierValue) throws TrafficException { LOG.trace("Updating Traffic on port(s) [" + portID + "], setting to " + multiplierValue + " pps"); LogsController.getInstance().appendText(LogType.INFO, "Updating Traffic on port(s) [" + portID + "], setting to " + multiplierValue + " pps"); Multiplier trafficMultiplier = new Multiplier(type, multiplierValue); String handler = (String) connectionHandler.get(portID); TrafficParams trafficParams = new TrafficParams(force, handler, trafficMultiplier, portID); try { String updateTrafficResponse = serverConnectionManager.sendRPCRequest(Constants.UPDATE_TRAFFIC_METHOD, trafficParams); return getMultiplierValue(updateTrafficResponse); } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) { throw new TrafficException(ex.toString()); } }
Example #5
Source File: RPCMethods.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
/** * * @param portID * @param force * @param type * @param multiplierValue * @param duration * @return multiplier value from the server * @throws com.exalttech.trex.remote.exceptions.TrafficException */ public double startTraffic(int portID, boolean force, String type, double multiplierValue, double duration) throws TrafficException { LogsController.getInstance().appendText(LogType.INFO, "Starting Traffic on Port " + portID); String handler = (String) connectionHandler.get(portID); Multiplier trafficMultiplier = new Multiplier(type, multiplierValue); TrafficParams trafficParams = new TrafficParams(force, handler, trafficMultiplier, portID); trafficParams.setDuration(duration); try { String updateTrafficResponse = serverConnectionManager.sendRPCRequest(Constants.START_TRAFFIC_METHOD, trafficParams); LOG.trace("Start Traffic response:" + updateTrafficResponse); return getMultiplierValue(updateTrafficResponse); } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) { throw new TrafficException(ex.toString()); } }
Example #6
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
public String sendPortXStatsValuesRequest(Port port) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException, SizeLimitExceededException { List<String> addStreamCommandList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); RPCRequest rpcRequest = new RPCRequest(); String jsonRequestString; rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH)); rpcRequest.setMethod(Constants.PORT_XSTATS_VALUES_METHOD); rpcRequest.setParams(port.getPortParam()); jsonRequestString = mapper.writeValueAsString(rpcRequest); jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH); addStreamCommandList.add(jsonRequestString); String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString()); LOG.info("Send port xstats_values request \n " + requestCommand); byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString()); return handleResponse(serverResponse, false); }
Example #7
Source File: UIFileManagementController.java From we-cmdb with Apache License 2.0 | 6 votes |
@RolesAllowed({ MENU_ADMIN_CMDB_MODEL_MANAGEMENT }) @PostMapping("/files/upload") @ResponseBody public Object uploadFile(@RequestParam(value = "file", required = false) MultipartFile file) throws SizeLimitExceededException { if (file.getSize() > applicationProperties.getMaxFileSize().toBytes()) { String errorMessage = String.format("Upload file failed due to file size (%s bytes) exceeded limitation (%s KB).", file.getSize(), applicationProperties.getMaxFileSize().toKilobytes()); log.warn(errorMessage); throw new CmdbException(errorMessage); } try { String contentType = file.getContentType(); return imageService.upload(file.getName(), contentType, file.getBytes()); } catch (IOException e) { String msg = String.format("Failed to upload image file. (fileName:%s)", file.getName()); log.warn(msg, e); throw new CmdbException(msg); } }
Example #8
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
String sendAddStreamRequest(Profile[] profilesList) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException, SizeLimitExceededException { List<String> addStreamCommandList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); RPCRequest rpcRequest = new RPCRequest(); String jsonRequestString; for (Profile aProfilesList : profilesList) { rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH)); rpcRequest.setMethod(Constants.ADD_STREAM_METHOD); rpcRequest.setParams(aProfilesList); jsonRequestString = mapper.writeValueAsString(rpcRequest); jsonRequestString = Util.tuneJSONParams(jsonRequestString, aProfilesList, apiH); addStreamCommandList.add(jsonRequestString); } List<List<String>> streamGroups = packMultipleRequestsIntoGroups(addStreamCommandList); StringBuilder response = new StringBuilder(); for (List<String> group : streamGroups) { response.append(sendStreamGroup(group)).append("\n"); } return response.toString(); }
Example #9
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
public String sendPortXStatsNamesRequest(Port port) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException, SizeLimitExceededException { List<String> addStreamCommandList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); RPCRequest rpcRequest = new RPCRequest(); String jsonRequestString; rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH)); rpcRequest.setMethod(Constants.PORT_XSTATS_NAMES_METHOD); rpcRequest.setParams(port.getPortParam()); jsonRequestString = mapper.writeValueAsString(rpcRequest); jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH); addStreamCommandList.add(jsonRequestString); String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString()); LOG.info("Send port xstats_names request \n " + requestCommand); byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString()); return handleResponse(serverResponse, false); }
Example #10
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 6 votes |
public String sendPortStatusRequest(List<Port> portList) throws JsonProcessingException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException, SizeLimitExceededException { List<String> addStreamCommandList = new ArrayList<>(); ObjectMapper mapper = new ObjectMapper(); RPCRequest rpcRequest = new RPCRequest(); String jsonRequestString; for (Port port : portList) { rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH)); rpcRequest.setMethod(Constants.PORT_STATUS_METHOD); rpcRequest.setParams(new GetPortStatusParams(port.getIndex(), false)); jsonRequestString = mapper.writeValueAsString(rpcRequest); jsonRequestString = Util.tuneJSONParams(jsonRequestString, port.getPortParam(), apiH); addStreamCommandList.add(jsonRequestString); } String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString()); LOG.info("Send port status request \n " + requestCommand); byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString()); return handleResponse(serverResponse, false); }
Example #11
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
String sendRPCRequest(String method, Params params) throws JsonProcessingException, UnsupportedEncodingException, InvalidRPCResponseException, IncorrectRPCMethodException, SizeLimitExceededException { RPCRequest rpcRequest = new RPCRequest(); ObjectMapper mapper = new ObjectMapper(); rpcRequest.setId(Util.getRandomID(Constants.RPC_REQUEST_ID_LENGTH)); rpcRequest.setMethod(method); if (params != null) { rpcRequest.setParams(params); } String jsonRequestString = mapper.writeValueAsString(rpcRequest); jsonRequestString = Util.tuneJSONParams(jsonRequestString, params, apiH); LOG.trace("Sending request \n" + Util.toPrettyFormat(jsonRequestString)); logProperty.setValue("Sending request " + Util.toPrettyFormat(jsonRequestString)); byte[] serverResponse = getServerRPCResponse(jsonRequestString); return handleResponse(serverResponse, true); }
Example #12
Source File: PubsubIO.java From beam with Apache License 2.0 | 5 votes |
@ProcessElement public void processElement(ProcessContext c) throws IOException, SizeLimitExceededException { byte[] payload; PubsubMessage message = getFormatFn().apply(c.element()); payload = message.getPayload(); Map<String, String> attributes = message.getAttributeMap(); if (payload.length > maxPublishBatchByteSize) { String msg = String.format( "Pub/Sub message size (%d) exceeded maximum batch size (%d)", payload.length, maxPublishBatchByteSize); throw new SizeLimitExceededException(msg); } // Checking before adding the message stops us from violating the max bytes if (((currentOutputBytes + payload.length) >= maxPublishBatchByteSize) || (output.size() >= maxPublishBatchSize)) { publish(); } // NOTE: The record id is always null. output.add( OutgoingMessage.of( com.google.pubsub.v1.PubsubMessage.newBuilder() .setData(ByteString.copyFrom(payload)) .putAllAttributes(attributes) .build(), c.timestamp().getMillis(), null)); currentOutputBytes += payload.length; }
Example #13
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
private String sendStreamGroup(List<String> addStreamCommandList) throws SizeLimitExceededException, UnsupportedEncodingException, IncorrectRPCMethodException, InvalidRPCResponseException { String requestCommand = Util.toPrettyFormat(addStreamCommandList.toString()); LOG.info(requestCommand); logProperty.setValue("Sending request " + requestCommand); byte[] serverResponse = getServerRPCResponse(addStreamCommandList.toString()); return handleResponse(serverResponse, false); }
Example #14
Source File: RPCMethods.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
/** * * @return true if the ping was successful false otherwise */ public Boolean pingRPCServer() { LOG.trace("Pinging RPC Server"); try { serverConnectionManager.sendRPCRequest(Constants.PING_METHOD, new PingParams()); LOG.trace("Ping OK"); return true; } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | NullPointerException | SizeLimitExceededException ex) { LOG.error("Failed to ping RPC Server", ex); return false; } }
Example #15
Source File: RPCMethods.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
private boolean buildCommonRPCRequest(int portID, String handler, String method) { CommonParams params = new CommonParams(portID, handler); try { serverConnectionManager.sendRPCRequest(method, params); return true; } catch (JsonProcessingException | UnsupportedEncodingException | InvalidRPCResponseException | IncorrectRPCMethodException | SizeLimitExceededException ex) { return false; } }
Example #16
Source File: ConnectionManager.java From trex-stateless-gui with Apache License 2.0 | 4 votes |
private byte[] getServerRPCResponse(String request) throws SizeLimitExceededException { byte[] finalRequest = this.dataCompressor.compressStringToBytes(request); if (finalRequest.length >= MAX_REQUEST_SIZE) { throw new SizeLimitExceededException(MessageFormat.format("Size of request is too large (limit is {0} bytes)", MAX_REQUEST_SIZE)); } byte[] serverResponse; boolean success; synchronized (sendRequestMonitor) { if (connectionTimeout.get()) { return null; } try { success = requester.send(finalRequest); } catch (ZMQException e) { if (e.getErrorCode() == ZError.EFSM) { success = resend(finalRequest); } else { throw e; } } if (success) { serverResponse = requester.recv(0); if (serverResponse == null) { if (requester.base().errno() == ZError.EAGAIN) { int retries = timeout / INTERNAL_TIMEOUT; while (serverResponse == null && retries > 0) { if (connectionTimeout.get()) { return null; } retries--; serverResponse = requester.recv(0); } if (retries == 0 && resend(finalRequest)) { serverResponse = requester.recv(0); } } else { LOG.error("Error sending request"); } } } else { LOG.error("Error sending request"); return null; } } return serverResponse == null ? null : dataCompressor.decompressBytesToString(serverResponse).getBytes(); }
Example #17
Source File: OpenLDAPModifyPasswordRequest.java From ldapchai with GNU Lesser General Public License v2.1 | 4 votes |
/** * Creates a new <code>OpenLDAPUser</code> instance. * * @param dn the dn whose password is to change * @param password the new password * @param chaiConfiguration appropriate chaiConfiguration * @throws NullPointerException if dn or password is null * @throws javax.naming.SizeLimitExceededException when the dn or password * is too long */ public OpenLDAPModifyPasswordRequest( final String dn, final String password, final ChaiConfiguration chaiConfiguration ) throws NullPointerException, SizeLimitExceededException { this.chaiConfiguration = chaiConfiguration; if ( dn == null ) { throw new NullPointerException( "dn cannot be null" ); } if ( password == null ) { throw new NullPointerException( "password cannot be null" ); } final int dnlen = dn.length(); final int passlen = password.length(); final int totallen = 4 + dnlen + passlen; if ( dnlen <= 0 ) { throw new SizeLimitExceededException( "dn cannot be 0 length" ); } if ( dnlen > 0xFF ) { throw new SizeLimitExceededException( "dn cannot be larger then 255 characters" ); } if ( passlen <= 0 ) { throw new SizeLimitExceededException( "password cannot be 0 length" ); } if ( passlen > 0xFF ) { throw new SizeLimitExceededException( "password cannot be larger then 255 characters" ); } if ( totallen > 0xFF ) { throw new SizeLimitExceededException( "the length of the dn + the lengh of the password cannot" + " exceed 251 characters" ); } modifyDn = dn; modifyPassword = password; }