本文整理汇总了Java中org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder类的典型用法代码示例。如果您正苦于以下问题:Java MessageDigestPasswordEncoder类的具体用法?Java MessageDigestPasswordEncoder怎么用?Java MessageDigestPasswordEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageDigestPasswordEncoder类属于org.springframework.security.authentication.encoding包,在下文中一共展示了MessageDigestPasswordEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MongoPasswordHasherConfiguration
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public MongoPasswordHasherConfiguration(SecurityConfigurationProperties securityConfig) {
if (StringUtils.isNotBlank(securityConfig.getMongo().getPasswordHasher())) {
passwordEncoder = new MessageDigestPasswordEncoder(securityConfig.getMongo().getPasswordHasher());
} else {
passwordEncoder = null;
}
}
示例2: addSessionContextToLogging
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
private void addSessionContextToLogging() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String tokenValue = "EMPTY";
if (authentication != null && !Strings.isNullOrEmpty(authentication.getDetails().toString())) {
MessageDigestPasswordEncoder encoder = new MessageDigestPasswordEncoder("SHA-1");
tokenValue = encoder.encodePassword(authentication.getDetails().toString(), "not_so_random_salt");
}
MDC.put(TOKEN_SESSION_KEY, tokenValue);
String userValue = "EMPTY";
if (authentication != null && !Strings.isNullOrEmpty(authentication.getPrincipal().toString())) {
userValue = authentication.getPrincipal().toString();
}
MDC.put(USER_SESSION_KEY, userValue);
}
示例3: resetSuperUserPasswordIfNecessary
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
private static final boolean resetSuperUserPasswordIfNecessary(RegisteredUsersTable t,
boolean newUser, MessageDigestPasswordEncoder mde, CallingContext cc)
throws ODKEntityPersistException, ODKOverQuotaException, ODKEntityNotFoundException {
String localSuperUser = t.getUsername();
String currentRealmString = cc.getUserService().getCurrentRealm().getRealmString();
String lastKnownRealmString = ServerPreferencesProperties.getLastKnownRealmString(cc);
if (!newUser && lastKnownRealmString != null && lastKnownRealmString.equals(currentRealmString)) {
// no need to reset the passwords
return false;
}
// The realm string has changed, so we need to reset the password.
RealmSecurityInfo r = new RealmSecurityInfo();
r.setRealmString(currentRealmString);
r.setBasicAuthHashEncoding(mde.getAlgorithm());
CredentialsInfo credential;
try {
credential = CredentialsInfoBuilderInternal.build(localSuperUser, r, "aggregate");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new IllegalStateException("unrecognized algorithm");
}
t.setDigestAuthPassword(credential.getDigestAuthHash());
t.setBasicAuthPassword(credential.getBasicAuthHash());
t.setBasicAuthSalt(credential.getBasicAuthSalt());
// done setting the password...persist it...
t.setIsRemoved(false);
cc.getDatastore().putEntity(t, cc.getCurrentUser());
// remember the current realm string
ServerPreferencesProperties.setLastKnownRealmString(cc, currentRealmString);
logger.warn("Reset password of the local superuser record: " + t.getUri() + " identified by: "
+ t.getUsername());
return true;
}
示例4: getRealmInfo
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
@Override
public RealmSecurityInfo getRealmInfo(String xsrfString) throws AccessDeniedException, DatastoreFailureException {
HttpServletRequest req = this.getThreadLocalRequest();
CallingContext cc = ContextFactory.getCallingContext(this, req);
if (!req.getSession().getId().equals(xsrfString)) {
throw new AccessDeniedException("Invalid request");
}
RealmSecurityInfo r = new RealmSecurityInfo();
r.setRealmString(cc.getUserService().getCurrentRealm().getRealmString());
MessageDigestPasswordEncoder mde = (MessageDigestPasswordEncoder) cc
.getBean(SecurityBeanDefs.BASIC_AUTH_PASSWORD_ENCODER);
r.setBasicAuthHashEncoding(mde.getAlgorithm());
r.setSuperUserEmail(cc.getUserService().getSuperUserEmail());
r.setSuperUsername(cc.getUserService().getSuperUserUsername());
try {
r.setSuperUsernamePasswordSet(cc.getUserService().isSuperUsernamePasswordSet(cc));
} catch (ODKDatastoreException e) {
e.printStackTrace();
throw new DatastoreFailureException("Unable to access datastore");
}
// User interface layer uses this URL to submit password changes securely
r.setChangeUserPasswordURL(cc.getSecureServerURL() + BasicConsts.FORWARDSLASH
+ UserManagePasswordsServlet.ADDR);
return r;
}
示例5: encodePassword
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public static String encodePassword(String clearTextPassword) {
return new MessageDigestPasswordEncoder("MD5", true).encodePassword(clearTextPassword, null);
}
示例6: encode
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
private static String encode(String password) {
return new MessageDigestPasswordEncoder("MD5", true).encodePassword(password, null);
}
示例7: encodePasswordByMD5
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
/**
* 采用md5进行信息摘要加密
*/
public static String encodePasswordByMD5(String password,String key){
return new MessageDigestPasswordEncoder("MD5").encodePassword(password,key);
}
示例8: hashPassword
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
@Override
public String hashPassword(String password) {
return new MessageDigestPasswordEncoder(AppConstants.SHA_256.toString()).encodePassword(password, null);
}
示例9: AbstractCoreMessageDigestPasswordEncoder
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
protected AbstractCoreMessageDigestPasswordEncoder(MessageDigestPasswordEncoder delegate) {
this.delegate = delegate;
}
示例10: getPasswordEncoder
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public MessageDigestPasswordEncoder getPasswordEncoder() {
return passwordEncoder;
}
示例11: setPasswordEncoder
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public void setPasswordEncoder(MessageDigestPasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
示例12: getHash
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public String getHash(String id, String pass) {
MessageDigestPasswordEncoder mdpe = new MessageDigestPasswordEncoder("MD5");
return mdpe.encodePassword(pass, id);
}
示例13: getHash
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
private static String getHash(String id, String pass)
{
MessageDigestPasswordEncoder mdpe = new MessageDigestPasswordEncoder(
"MD5");
return mdpe.encodePassword(pass, id);
}
示例14: setPasswordEncoder
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
public void setPasswordEncoder(MessageDigestPasswordEncoder passwordEncoder) {
this.passwordEncoder = passwordEncoder;
}
示例15: getEncodedPassword
import org.springframework.security.authentication.encoding.MessageDigestPasswordEncoder; //导入依赖的package包/类
/**
* Gets the MD5 hash and encodes it in Base 64 notation
*
* @param clearTextPassword
* @return
* @throws NoSuchAlgorithmException
*/
public static String getEncodedPassword(String clearTextPassword) {
return new MessageDigestPasswordEncoder("MD5", true).encodePassword(clearTextPassword, null);
}