List of usage examples for org.apache.commons.codec.binary Base64 encodeBase64String
public static String encodeBase64String(final byte[] binaryData)
From source file:com.lingxiang2014.controller.shop.CommonController.java
@RequestMapping(value = "/public_key", method = RequestMethod.GET) public @ResponseBody Map<String, String> publicKey(HttpServletRequest request) { RSAPublicKey publicKey = rsaService.generateKey(request); Map<String, String> data = new HashMap<String, String>(); data.put("modulus", Base64.encodeBase64String(publicKey.getModulus().toByteArray())); data.put("exponent", Base64.encodeBase64String(publicKey.getPublicExponent().toByteArray())); return data;// w w w .j a v a2s . c o m }
From source file:io.smartspaces.scheduling.quartz.orientdb.internal.util.SerialUtils.java
public static String serialize(JobDataMap jobDataMap) throws IOException { try {//from ww w .j a v a 2 s . com byte[] bytes = stringMapToBytes(jobDataMap.getWrappedMap()); return Base64.encodeBase64String(bytes); } catch (NotSerializableException e) { return rethrowEnhanced(jobDataMap, e); } }
From source file:de.cosmocode.palava.captcha.Create.java
@Override public void execute(IpcCall call, Map<String, Object> result) throws IpcCommandExecutionException { final IpcConnection connection = call.getConnection(); final IpcSession session = connection.getSession(); final String sessionId = session.getSessionId(); final byte[] binary = captcha.getCaptcha(sessionId); LOG.trace("Created captcha challenge for {}", sessionId); final String base64 = Base64.encodeBase64String(binary); result.put("base64", base64); }
From source file:io.apiman.test.policies.PolicyTestRequest.java
public PolicyTestRequest basicAuth(String username, String password) { return header("Authorization", //$NON-NLS-1$ "Basic " + Base64.encodeBase64String((username + ':' + password).getBytes())); //$NON-NLS-1$ }
From source file:com.esri.geoevent.test.performance.utils.KryoUtils.java
public static <T> String toString(T t, Class<T> type) { if (t == null) return null; Kryo kryo = setupKryo();//from w w w .ja v a2 s .c o m ByteArrayOutputStream baos = new ByteArrayOutputStream(); Output output = new Output(baos); kryo.writeObject(output, t); output.close(); return Base64.encodeBase64String(baos.toByteArray()); }
From source file:net.officefloor.plugin.web.http.security.store.PasswordFileCredentialStoreTest.java
/** * Logs the credentials to put into the password file. *///from w w w. j a v a 2s. c om public void testShowCredentials() { assertEquals("Incorrect credentials", "Y3JlZGVudGlhbHM=", Base64.encodeBase64String("credentials".getBytes(HttpRequestParserImpl.US_ASCII)).trim()); }
From source file:com.streamsets.lib.security.util.DataSignature.java
public String encodePublicKey(PublicKey publicKey) { return Base64.encodeBase64String(publicKey.getEncoded()); }
From source file:com.cl.roadshow.crypto.AESCtr.java
/** * Strong (128 bits) encryption of message using first 16 characters from key. * /* w w w . ja va 2 s .c o m*/ * @param key The encryption key (use 256bits hash!) * @param message The message to encrypt * @return base64 encoded string */ public static String encrypt128(String key, String message) throws Exception { return Base64.encodeBase64String(encrypt(key, message, BITS128)); }
From source file:com.mashape.unirest.request.HttpRequest.java
public HttpRequest basicAuth(String username, String password) { header("Authorization", "Basic " + Base64.encodeBase64String((username + ":" + password).getBytes())); return this; }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.networking.OslpSecurityHandler.java
@Override public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt) throws Exception { final OslpEnvelope message = (OslpEnvelope) evt.getMessage(); // Upon first registration, a deviceUid is unknown within the platform. // Search based on deviceIdentification in this case. OslpDevice oslpDevice = null;/*from w w w . j a v a2 s . c om*/ if (message.getPayloadMessage().hasRegisterDeviceRequest()) { final String deviceIdentification = message.getPayloadMessage().getRegisterDeviceRequest() .getDeviceIdentification(); oslpDevice = this.oslpDeviceSettingsService.getDeviceByDeviceIdentification(deviceIdentification); } else { oslpDevice = this.oslpDeviceSettingsService .getDeviceByUid(Base64.encodeBase64String(message.getDeviceId())); } if (oslpDevice == null) { LOGGER.warn("Received message from unknown device."); } else if (oslpDevice.getPublicKey() == null) { LOGGER.warn("Received message from device without public key: {}", oslpDevice.getDeviceIdentification()); } // When device is unknown or publickey is not available, the message is // not valid. if (oslpDevice != null && oslpDevice.getPublicKey() != null) { final PublicKey publicKey = CertificateHelper.createPublicKeyFromBase64(oslpDevice.getPublicKey(), this.oslpKeyType, this.oslpSignatureProvider); message.validate(publicKey); } ctx.sendUpstream(evt); }