public static String randomId() { return StringUtils.randomString(24); } }
public JingleIBBTransport(short blockSize) { this(blockSize, StringUtils.randomString(24)); }
@Override public void actionPerformed(ActionEvent e) { adhocMessages.setText( "<message to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><body></body></message>"); } });
@Override public void actionPerformed(ActionEvent e) { adhocMessages.setText( "<iq type=\"get\" to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><query xmlns=\"\"></query></iq>"); } });
@Override public void actionPerformed(ActionEvent e) { adhocMessages.setText( "<iq type=\"set\" to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"><query xmlns=\"\"></query></iq>"); } });
@Override public void actionPerformed(ActionEvent e) { adhocMessages.setText( "<presence to=\"\" id=\"" + StringUtils.randomString(5) + "-X\"/>"); } });
public static String randomString(final int length) { return randomString(length, SECURE_RANDOM.get()); }
private static String createRandomPadding() { SecureRandom secRan = new SecureRandom(); int len = secRan.nextInt(256); return StringUtils.randomString(len); }
/** * Returns a random String of numbers and letters (lower and upper case) * of the specified length. The method uses the Random class that is * built-in to Java which is suitable for low to medium grade security uses. * This means that the output is only pseudo random, i.e., each number is * mathematically generated so is not truly random.<p> * * The specified length must be at least one. If not, the method will return * null. * * @param length the desired length of the random String to return. * @return a random String of numbers and letters of the specified length. */ public static String insecureRandomString(int length) { return randomString(length, randGen.get()); }
public JingleS5BTransportCandidate(Bytestream.StreamHost streamHost, int priority, Type type) { this(StringUtils.randomString(24), streamHost.getAddress(), streamHost.getJID(), streamHost.getPort(), priority, type); }
@Test public void testRandomString() { // Boundary test String result = StringUtils.randomString(-1); assertNull(result); // Zero length string test result = StringUtils.randomString(0); assertNull(result); // Test various lengths - make sure the same length is returned result = StringUtils.randomString(4); assertTrue(result.length() == 4); result = StringUtils.randomString(16); assertTrue(result.length() == 16); result = StringUtils.randomString(128); assertTrue(result.length() == 128); } }
cnonce = StringUtils.randomString(32); byte[] a1 = ByteUtils.concat(a1FirstPart, toBytes(':' + nonce + ':' + cnonce)); digestUri = "xmpp/" + serviceName;
private static ThingState actAsDataThing(XMPPTCPConnection connection) throws XMPPException, SmackException, InterruptedException { final String key = StringUtils.randomString(12); final String sn = StringUtils.randomString(12); Thing dataThing = Thing.builder() .setKey(key) .setSerialNumber(sn) .setManufacturer("IgniteRealtime") .setModel("Smack") .setVersion("0.1") .setMomentaryReadOutRequestHandler(new ThingMomentaryReadOutRequest() { @Override public void momentaryReadOutRequest(ThingMomentaryReadOutResult callback) { IoTDataField.IntField field = new IntField("timestamp", (int) (System.currentTimeMillis() / 1000)); callback.momentaryReadOut(Collections.singletonList(field)); } }) .build(); IoTDiscoveryManager iotDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection); ThingState state = IoTDiscoveryIntegrationTest.registerThing(iotDiscoveryManager, dataThing); printStatus("SUCCESS: Thing registered:" + dataThing); return state; }
final String key = StringUtils.randomString(12); final String sn = StringUtils.randomString(12); final int value = INSECURE_RANDOM.nextInt();
@SmackIntegrationTest public void registerClaimAndUnregisterThing() throws XMPPErrorException, InterruptedException, SmackException { final String key = StringUtils.randomString(12); final String sn = StringUtils.randomString(12); final Thing thing = Thing.builder().setKey(key).setSerialNumber(sn).setManufacturer("Ignite Realtime").setModel( "Smack").setVersion("0.1").build(); registerThing(discoveryManagerOne, thing); IoTClaimed iotClaimed = discoveryManagerTwo.claimThing(thing.getMetaTags()); assertEquals(conOne.getUser().asBareJid(), iotClaimed.getJid()); discoveryManagerTwo.disownThing(iotClaimed.getJid()); discoveryManagerOne.unregister(); }
@SmackIntegrationTest public void outgoingMessageListenerTest() throws Exception { final String body = StringUtils.randomString(16); final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint(); final OutgoingChatMessageListener listener = new OutgoingChatMessageListener() { @Override public void newOutgoingMessage(EntityBareJid to, Message message, Chat chat) { if (message.getBody().equals(body)) { syncPoint.signal(); } } }; EntityBareJid peer = conTwo.getUser().asEntityBareJid(); try { chatManagerOne.addOutgoingListener(listener); Chat chat = chatManagerOne.chatWith(peer); chat.send(body); syncPoint.waitForResult(timeout); } finally { chatManagerOne.removeOutgoingListener(listener); } } }
@SmackIntegrationTest public void test() throws Exception { final String body = StringUtils.randomString(16); final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint(); final IncomingChatMessageListener listener = new IncomingChatMessageListener() { @Override public void newIncomingMessage(EntityBareJid from, Message message, Chat chat) { if (body.equals(message.getBody())) { syncPoint.signal(); } } }; try { chatManagerTwo.addIncomingListener(listener); Chat chat = chatManagerOne.chatWith(conTwo.getUser().asEntityBareJid()); chat.send(body); syncPoint.waitForResult(timeout); } finally { chatManagerTwo.removeIncomingListener(listener); } } }
final String key = StringUtils.randomString(12); final String sn = StringUtils.randomString(12); final SimpleResultSyncPoint syncPoint = new SimpleResultSyncPoint();
@SmackIntegrationTest public void testMucBookmarksAutojoin(XMPPTCPConnection connection) throws InterruptedException, TestNotPossibleException, XMPPException, SmackException, IOException { final BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(connection); if (!bookmarkManager.isSupported()) { throw new TestNotPossibleException("Private data storage not supported"); } final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection); final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6)); final String randomMucName = StringUtils.randomString(6); final DomainBareJid mucComponent = multiUserChatManager.getMucServiceDomains().get(0); final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom( Localpart.from(randomMucName), mucComponent)); MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname); if (handle != null) { handle.makeInstant(); } muc.leave(); bookmarkManager.addBookmarkedConference("Smack Inttest: " + testRunId, muc.getRoom(), true, mucNickname, null); connection.disconnect(); connection.connect().login(); // MucBookmarkAutojoinManager is also able to do its task automatically // after every login, it's not deterministic when this will be finished. // So we trigger it manually here. MucBookmarkAutojoinManager.getInstanceFor(connection).autojoinBookmarkedConferences(); assertTrue(muc.isJoined()); // If the test went well, leave the MUC muc.leave(); }
@Test public void parserTest() throws Exception { String sid = StringUtils.randomString(24); short size = 8192;