本文整理了Java中org.apache.shiro.codec.Base64.encodeToString()
方法的一些代码示例,展示了Base64.encodeToString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encodeToString()
方法的具体详情如下:
包路径:org.apache.shiro.codec.Base64
类名称:Base64
方法名:encodeToString
[英]Base64 encodes the specified byte array and then encodes it as a String using Shiro's preferred character encoding (UTF-8).
[中]Base64对指定的字节数组进行编码,然后使用Shiro的首选字符编码(UTF-8)将其编码为字符串。
代码示例来源:origin: shuzheng/zheng
public static String serialize(Session session) {
if (null == session) {
return null;
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(session);
return Base64.encodeToString(bos.toByteArray());
} catch (Exception e) {
throw new RuntimeException("serialize session error", e);
}
}
代码示例来源:origin: apache/shiro
public String toBase64() {
if ( this.cachedBase64 == null ) {
this.cachedBase64 = Base64.encodeToString(getBytes());
}
return this.cachedBase64;
}
代码示例来源:origin: apache/shiro
/**
* Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
* <p/>
* This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
* However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
* next time this method is called.
*
* @return a Base64-encoded string of the underlying {@link #getBytes byte array}.
*/
public String toBase64() {
if (this.base64Encoded == null) {
//cache result in case this method is called multiple times.
this.base64Encoded = Base64.encodeToString(getBytes());
}
return this.base64Encoded;
}
代码示例来源:origin: apache/shiro
/**
* Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
* <p/>
* This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
* However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
* next time this method is called.
*
* @return a Base64-encoded string of the underlying {@link #getBytes byte array}.
*/
public String toBase64() {
if (this.base64Encoded == null) {
//cache result in case this method is called multiple times.
this.base64Encoded = Base64.encodeToString(getBytes());
}
return this.base64Encoded;
}
代码示例来源:origin: apache/shiro
/**
* Base64-encodes the specified serialized byte array and sets that base64-encoded String as the cookie value.
* <p/>
* The {@code subject} instance is expected to be a {@link WebSubject} instance with an HTTP Request/Response pair
* so an HTTP cookie can be set on the outgoing response. If it is not a {@code WebSubject} or that
* {@code WebSubject} does not have an HTTP Request/Response pair, this implementation does nothing.
*
* @param subject the Subject for which the identity is being serialized.
* @param serialized the serialized bytes to be persisted.
*/
protected void rememberSerializedIdentity(Subject subject, byte[] serialized) {
if (!WebUtils.isHttp(subject)) {
if (log.isDebugEnabled()) {
String msg = "Subject argument is not an HTTP-aware instance. This is required to obtain a servlet " +
"request and response in order to set the rememberMe cookie. Returning immediately and " +
"ignoring rememberMe operation.";
log.debug(msg);
}
return;
}
HttpServletRequest request = WebUtils.getHttpRequest(subject);
HttpServletResponse response = WebUtils.getHttpResponse(subject);
//base 64 encode it and store as a cookie:
String base64 = Base64.encodeToString(serialized);
Cookie template = getCookie(); //the class attribute is really a template for the outgoing cookies
Cookie cookie = new SimpleCookie(template);
cookie.setValue(base64);
cookie.saveTo(request, response);
}
代码示例来源:origin: be.c4j.ee.security.octopus/octopus-core
public String base64Encode(byte[] value) {
return Base64.encodeToString(value);
}
代码示例来源:origin: be.c4j.ee.security.octopus/octopus-core
/**
*
* @deprecated use base64Encode
*/
@Deprecated
public String Base64Encode(byte[] salt) {
return Base64.encodeToString(salt);
}
代码示例来源:origin: org.opendaylight.aaa/aaa-shiro
/**
*
* @param credentialToken
* @return Base64 encoded token
*/
static String getEncodedToken(final String credentialToken) {
return Base64.encodeToString(credentialToken.getBytes());
}
代码示例来源:origin: be.c4j.ee.security.octopus/octopus-core
public String generateSecretBase64(int byteLength) {
byte[] secret = new byte[byteLength];
secureRandom.nextBytes(secret);
return Base64.encodeToString(secret);
}
代码示例来源:origin: 417511458/jbone
public static String serialize(Session session) {
if (null == session) {
return null;
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(session);
return Base64.encodeToString(bos.toByteArray());
} catch (Exception e) {
throw new RuntimeException("serialize session error", e);
}
}
代码示例来源:origin: liunian1004/vua
public static String serialize(Session session) {
if (null == session) {
return null;
}
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(session);
return Base64.encodeToString(bos.toByteArray());
} catch (Exception e) {
throw new RuntimeException("serialize session error", e);
}
}
代码示例来源:origin: org.apache.shiro/shiro-lang
public String toBase64() {
if ( this.cachedBase64 == null ) {
this.cachedBase64 = Base64.encodeToString(getBytes());
}
return this.cachedBase64;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro
public String toBase64() {
if ( this.cachedBase64 == null ) {
this.cachedBase64 = Base64.encodeToString(getBytes());
}
return this.cachedBase64;
}
代码示例来源:origin: TomChen001/xmanager
@Override
public String toBase64() {
if ( this.cachedBase64 == null ) {
this.cachedBase64 = Base64.encodeToString(getBytes());
}
return this.cachedBase64;
}
代码示例来源:origin: SomMeri/matasano-cryptopals-solutions
/**
* Exercise 1: I used apache shiro {@link http://shiro.apache.org/} to encode
* and decode stuff.
*/
public String hexToBase64(String hex) {
byte[] raw = Hex.decode(hex);
return Base64.encodeToString(raw);
}
代码示例来源:origin: org.apache.shiro/shiro-crypto-hash
/**
* Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
* <p/>
* This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
* However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
* next time this method is called.
*
* @return a Base64-encoded string of the underlying {@link #getBytes byte array}.
*/
public String toBase64() {
if (this.base64Encoded == null) {
//cache result in case this method is called multiple times.
this.base64Encoded = Base64.encodeToString(getBytes());
}
return this.base64Encoded;
}
代码示例来源:origin: sonia.scm/scm-core
/**
* Enabled http basic authentication.
*
*
* @param username username for http basic authentication
* @param password password for http basic authentication
*
* @return http request instance
*/
public T basicAuth(String username, String password)
{
String auth = Strings.nullToEmpty(username).concat(":").concat(
Strings.nullToEmpty(password));
auth = Base64.encodeToString(auth.getBytes(Charsets.ISO_8859_1));
headers.put("Authorization", "Basic ".concat(auth));
return self();
}
代码示例来源:origin: org.apache.shiro/shiro-crypto-hash
/**
* Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
* <p/>
* This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
* However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
* next time this method is called.
*
* @return a Base64-encoded string of the underlying {@link #getBytes byte array}.
*/
public String toBase64() {
if (this.base64Encoded == null) {
//cache result in case this method is called multiple times.
this.base64Encoded = Base64.encodeToString(getBytes());
}
return this.base64Encoded;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.shiro
/**
* Returns a Base64-encoded string of the underlying {@link #getBytes byte array}.
* <p/>
* This implementation caches the resulting Base64 string so multiple calls to this method remain efficient.
* However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the
* next time this method is called.
*
* @return a Base64-encoded string of the underlying {@link #getBytes byte array}.
*/
public String toBase64() {
if (this.base64Encoded == null) {
//cache result in case this method is called multiple times.
this.base64Encoded = Base64.encodeToString(getBytes());
}
return this.base64Encoded;
}
代码示例来源:origin: com.haoxuer.discover/discover-common-user-hibernate
private String key() {
String key = optionDao.key("option_token_config");
if (key == null) {
Key temp = MacProvider.generateKey();
key = Base64.encodeToString(temp.getEncoded());
optionDao.put("option_token_config", key);
}
return key;
}
内容来源于网络,如有侵权,请联系作者删除!