List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64URLSafeString
public static String encodeBase64URLSafeString(final byte[] binaryData)
From source file:org.sonar.core.util.UuidFactoryImpl.java
@Override public String create() { return Base64.encodeBase64URLSafeString(uuidGenerator.generate()); }
From source file:org.soulwing.cas.server.service.TicketServiceBean.java
/** * {@inheritDoc}/*from w ww . j a v a2 s .c o m*/ */ @Override public Ticket issue() { TicketValue prior = null; TicketValue ticket = null; byte[] data = new byte[18]; do { secureRandom.nextBytes(data); String id = Base64.encodeBase64URLSafeString(data); ticket = new TicketValue(id, loginContext.getUsername()); prior = ticketCache.putIfAbsent(id, ticket); } while (prior != null); return ticket; }
From source file:org.structr.websocket.StructrWebSocket.java
public static String secureRandomString() { byte[] binaryData = new byte[SessionIdLength]; // create random data secureRandom.nextBytes(binaryData);//from w w w . j a v a 2 s .c o m // return random data encoded in Base64 return Base64.encodeBase64URLSafeString(binaryData); }
From source file:org.teatrove.teaapps.contexts.EncodingContext.java
/** * Base64 encode the given string. The encoded string is also considered * URL-safe by properly encoding '+' and '/' characters. * // w w w. j a v a2 s .co m * @param str The string to encode * * @return The Base64 encoded string * * @see Base64#encodeBase64String(byte[]) * @see #decodeBase64(String) */ public String encodeBase64(String str) { return Base64.encodeBase64URLSafeString(str.getBytes()); }
From source file:org.tuleap.mylyn.task.core.tests.internal.repository.TuleapTaskAttachmentHandlerTests.java
/** * Test posting the file content with non null attachment attribute.. * * @throws CoreException/*w w w . j a va2s. c o m*/ * @throws IOException * @throws URISyntaxException */ @Test public void testPostFirstAttachment() throws CoreException, URISyntaxException, IOException { TuleapTaskAttachmentHandler attachmentHandler = new TuleapTaskAttachmentHandler(repositoryConnector, clientManager); ITask task = new LocalTask("123:101#42", "label"); TextTaskAttachmentSource source = new TextTaskAttachmentSource("Text to post"); attachmentHandler.postContent(repository, task, source, "This is a comment"/* Ignored */, attachmentAttribute, null); assertEquals("{\"values\":[{\"field_id\":666,\"value\":[50]}]}", artifactWithAttachment); assertEquals(Base64.encodeBase64URLSafeString(StringUtils.getBytesUtf8("Text to post")), dataToPost); // fileIdentifier not updated since update not called assertEquals(-1, fileIdentifier); // update must not have been called since chunk is small assertNull(dataToUpdate); }
From source file:org.tuleap.mylyn.task.core.tests.internal.repository.TuleapTaskAttachmentHandlerTests.java
/** * Test posting the file content with non null attachment attribute.. * * @throws CoreException// w w w . j a v a2s .co m * @throws IOException * @throws URISyntaxException */ @Test public void testPostAttachmentWhenTheresAlreadyOne() throws CoreException, URISyntaxException, IOException { // Change the current state of artifact to update so thyat it already has one attachment artifactBeforeUpdate.addFieldValue(new AttachmentFieldValue(666, Arrays.asList( new AttachmentValue("777", "att 777", 0, 1500, "desc", "image/png", "/artifact_files/777")))); TuleapTaskAttachmentHandler attachmentHandler = new TuleapTaskAttachmentHandler(repositoryConnector, clientManager); ITask task = new LocalTask("123:101#42", "label"); TextTaskAttachmentSource source = new TextTaskAttachmentSource("Text to post"); attachmentHandler.postContent(repository, task, source, "This is a comment"/* Ignored */, attachmentAttribute, null); assertEquals("{\"values\":[{\"field_id\":666,\"value\":[777,50]}]}", artifactWithAttachment); assertEquals(Base64.encodeBase64URLSafeString(StringUtils.getBytesUtf8("Text to post")), dataToPost); // fileIdentifier not updated since update not called assertEquals(-1, fileIdentifier); // update must not have been called since chunk is small assertNull(dataToUpdate); }
From source file:org.wso2.carbon.apimgt.impl.token.URLSafeJWTGenerator.java
public String encode(byte[] stringToBeEncoded) throws APIManagementException { return Base64.encodeBase64URLSafeString(stringToBeEncoded); }
From source file:org.wso2.carbon.identity.oidc.session.DefaultOIDCSessionStateManager.java
private static String generateSaltValue() throws NoSuchAlgorithmException { byte[] bytes = new byte[16]; SecureRandom secureRandom = SecureRandom.getInstance(RANDOM_ALG_SHA1); secureRandom.nextBytes(bytes);/*from w ww.j a va 2 s. co m*/ return Base64.encodeBase64URLSafeString(bytes); }
From source file:org.wso2.carbon.ss.integration.test.rssmanager.RSSTenantMgtTest.java
private static String getDatabaseUserPostfix(String tenantDomain) { byte[] bytes = intToByteArray(tenantDomain.hashCode()); return Base64.encodeBase64URLSafeString(bytes).replace("_", "$"); }
From source file:org.wso2.identity.integration.test.user.export.UserInfoExportTestCase.java
private String getResourceId() { return Base64.encodeBase64URLSafeString(username.getBytes()).trim(); }