本文整理汇总了Java中org.springframework.security.crypto.codec.Utf8类的典型用法代码示例。如果您正苦于以下问题:Java Utf8类的具体用法?Java Utf8怎么用?Java Utf8使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utf8类属于org.springframework.security.crypto.codec包,在下文中一共展示了Utf8类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createToken
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
@Override
public TokenData createToken(TokenConfiguration config) {
final long creationTime = System.currentTimeMillis();
byte[] serverSecret = computeServerSecretApplicableAt(creationTime);
byte[] content = contentPack(creationTime,
generateRandom(),
serverSecret,
Utf8.encode(pack(config.getUserName(), config.getDeviceHash())));
byte[] sign = sign(content);
ByteBuffer buffer = ByteBuffer.allocate(1 + sign.length + 1 + content.length);
store(buffer, content);
store(buffer, sign);
String key = base32.encodeAsString(buffer.array());
return new TokenDataImpl(creationTime,
TokenUtils.getKeyWithTypeAndToken(TYPE, key),
config.getUserName(),
config.getDeviceHash());
}
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:22,代码来源:SignedTokenServiceBackend.java
示例2: MessageDigestPasswordEncoder
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
public MessageDigestPasswordEncoder(String algorithm, CharSequence secret) {
try {
messageDigest = MessageDigest.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("No such hashing algorithm", e);
}
this.secret = Utf8.encode(secret);
this.saltGenerator = KeyGenerators.secureRandom();
}
开发者ID:zhaojunfei,项目名称:lemon,代码行数:11,代码来源:MessageDigestPasswordEncoder.java
示例3: createECDSASignature
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
public static String createECDSASignature(final PrivateKey privateKey, final String payload) throws Exception {
Signature ecdsaSign = Signature.getInstance(SHA1WITH_ECDSA, JCE_PROVIDER);
ecdsaSign.initSign(privateKey);
ecdsaSign.update(Utf8.encode(payload));
return BaseEncoding.base64().encode(ecdsaSign.sign());
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:8,代码来源:JCEUtil.java
示例4: verifyECDSASignature
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
public static boolean verifyECDSASignature(String payload, String signature, PublicKey publicKey) throws Exception {
Signature ecdsaSign = Signature.getInstance(SHA1WITH_ECDSA, JCE_PROVIDER);
ecdsaSign.initVerify(publicKey);
ecdsaSign.update(Utf8.encode(payload));
return ecdsaSign.verify(BaseEncoding.base64().decode(signature));
}
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:9,代码来源:JCEUtil.java
示例5: getToken
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
@Override
public TokenData getToken(String tokenString) {
final String key = unwrapToken(tokenString);
if (key.isEmpty()) {
return null;
}
byte[] decodedKey = base32.decode(key);
byte[] currentSignature;
final long creationTime;
byte[] random;
byte[] payload;
{
byte[] content;
{
ByteBuffer buffer = ByteBuffer.wrap(decodedKey);
content = restoreArray(buffer);
currentSignature = restoreArray(buffer);
}
ByteBuffer contentBuffer = ByteBuffer.wrap(content);
creationTime = contentBuffer.getLong();
random = restoreArray(contentBuffer);
// we need to skip secret
restoreArray(contentBuffer);
payload = restoreArray(contentBuffer);
}
final byte[] serverSecret = computeServerSecretApplicableAt(creationTime);
// Verification
byte[] expectedSign = sign(contentPack(creationTime, random, serverSecret, payload));
Assert.isTrue(Arrays.equals(expectedSign, currentSignature), "Key verification failure");
String[] unpack = unpack(Utf8.decode(payload));
return new TokenDataImpl(creationTime, TokenUtils.getKeyWithTypeAndToken(TYPE, key), unpack[0], unpack[1]);
}
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:37,代码来源:SignedTokenServiceBackend.java
示例6: encodePassword
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
private String encodePassword(String rawPass, Object salt, String version) {
// パスワードのencodeのバージョンによって処理を変える
String saltedPass = mergePasswordAndSalt(rawPass, salt, false);
MessageDigest messageDigest = getMessageDigest(version);
byte[] digest = messageDigest.digest(Utf8.encode(saltedPass));
return version + ":" + (new String(Hex.encode(digest)));
}
开发者ID:kuwalab,项目名称:spring-security,代码行数:10,代码来源:CustomPasswordEncoder.java
示例7: computeServerSecretApplicableAt
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
private byte[] computeServerSecretApplicableAt(long time) {
return Utf8.encode(serverSecret + ":" + (time % serverInteger));
}
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:4,代码来源:SignedTokenServiceBackend.java
示例8: encrypt
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
public String encrypt(String text) {
return new String(Hex.encode(doFinal(encryptor, Utf8.encode(text))));
}
开发者ID:mqprichard,项目名称:spring-greenhouse-clickstart,代码行数:4,代码来源:UpdateEncryptionMethod.java
示例9: decrypt
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
public String decrypt(String encryptedText) {
return Utf8.decode(doFinal(decryptor, Hex.decode(encryptedText)));
}
开发者ID:mqprichard,项目名称:spring-greenhouse-clickstart,代码行数:4,代码来源:UpdateEncryptionMethod.java
示例10: GreenhousePasswordEncoder
import org.springframework.security.crypto.codec.Utf8; //导入依赖的package包/类
/**
* Creates a fully customized standard password encoder.
*/
public GreenhousePasswordEncoder(String algorithm, String provider, String secret) {
this.digester = new Digester(algorithm, provider);
this.secret = Utf8.encode(secret);
this.saltGenerator = KeyGenerators.secureRandom();
}
开发者ID:mqprichard,项目名称:spring-greenhouse-clickstart,代码行数:9,代码来源:GreenhousePasswordEncoder.java
注:本文中的org.springframework.security.crypto.codec.Utf8类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论