List of usage examples for org.apache.shiro.codec Base64 encodeToString
public static String encodeToString(byte[] bytes)
From source file:annis.security.BasicAuthOrAnonymousFilter.java
License:Apache License
@Override protected String getAuthzHeader(ServletRequest request) { String result = super.getAuthzHeader(request); if (result == null) { try {/*from w w w . jav a 2 s . com*/ // create an new one with anonymous user and password result = "Basic " + Base64.encodeToString((anonymousUser + ":" + anonymousPassword).getBytes("UTF-8")); } catch (UnsupportedEncodingException ex) { log.error(null, ex); } } return result; }
From source file:be.atbash.ee.security.octopus.book.ex7.KeyGeneration.java
License:Apache License
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(); byte[] key = new byte[16]; secureRandom.nextBytes(key);/* w ww. j a v a 2s . c om*/ System.out.println(Base64.encodeToString(key)); }
From source file:com.blazarquant.bfp.core.security.util.SecurityUtilImpl.java
License:Apache License
@Override public String generateConfirmationKey(long id, String username, String email) { if (username.isEmpty() || email.isEmpty()) { throw new IllegalArgumentException("Failed to generate confirmation key. Username or email is empty."); }/*from www . j av a 2 s . co m*/ return Base64.encodeToString( buildKeyBase(id, username, email).getBytes(BlazarFixParserConstants.DEFAULT_CHARSET)); }
From source file:com.blazarquant.bfp.core.security.util.SecurityUtilImpl.java
License:Apache License
@Override public String encodeMessage(String message) { return Base64.encodeToString(message.getBytes(BlazarFixParserConstants.DEFAULT_CHARSET)); }
From source file:com.flowlogix.services.test.PrincipalSerializationTests.java
License:Apache License
@Test public void serializer() { final Serializer<X> ser = new DefaultSerializer<>(); final String encoded = Base64.encodeToString(ser.serialize(new X(15, "xxx"))); assertEquals(new X(15, "xxx"), ser.deserialize(Base64.decode(encoded))); }
From source file:com.ikanow.aleph2.security.db.SerializableUtils.java
License:Apache License
public static String serialize(Object raw) { String str = null;//from w w w .ja va2s. co m try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(raw); str = Base64.encodeToString(bos.toByteArray()); } catch (Exception e) { logger.error("Caught exception serializing:", e); } return str; }
From source file:com.ikanow.aleph2.security.service.IkanowV1CredentialsMatcher.java
License:Apache License
/** * Encrypt the password/*from w w w. j a va2 s .co m*/ * @throws NoSuchAlgorithmException * @throws UnsupportedEncodingException */ public static String encrypt(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(password.getBytes("UTF-8")); return Base64.encodeToString(md.digest()); }
From source file:com.manydesigns.portofino.pageactions.crud.CrudAction4ItsProject.java
License:Open Source License
protected String toBase64(byte[] bytes) { return Base64.encodeToString(bytes); }
From source file:com.once.crosscloud.utils.EndecryptUtils.java
License:Apache License
/** * base64 /*from w w w . j av a 2 s .c om*/ * * @param password * @return */ public static String encrytBase64(String password) { byte[] bytes = password.getBytes(); return Base64.encodeToString(bytes); }
From source file:com.once.crosscloud.utils.EndecryptUtils.java
License:Apache License
public static String generateKey() { AesCipherService aesCipherService = new AesCipherService(); Key key = aesCipherService.generateNewKey(); return Base64.encodeToString(key.getEncoded()); }