本文整理汇总了Java中org.jivesoftware.openfire.auth.AuthFactory.encryptPassword方法的典型用法代码示例。如果您正苦于以下问题:Java AuthFactory.encryptPassword方法的具体用法?Java AuthFactory.encryptPassword怎么用?Java AuthFactory.encryptPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.auth.AuthFactory
的用法示例。
在下文中一共展示了AuthFactory.encryptPassword方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEncrypted
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
@Override
public String getEncrypted(String value) {
String encrypted = null;
try {
encrypted = AuthFactory.encryptPassword(value);
// Set password to null so that it's inserted that way.
} catch (UnsupportedOperationException uoe) {
// Encrypting the apiKey may have failed. Therefore,
}
return encrypted;
}
示例2: getEncrypted
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
/**
* Encrypt a string value using the openfire AuthFactory
* @param value
* @return
*/
protected String getEncrypted(String value) {
String encrypted = null;
try {
encrypted = AuthFactory.encryptPassword(value);
// Set password to null so that it's inserted that way.
} catch (UnsupportedOperationException uoe) {
// Encrypting the apiKey may have failed. Therefore,
}
return encrypted;
}
示例3: setPassword
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
/**
* Sets the password used for logging in to the transport.
*
* @param password new password for registration.
*/
public void setPassword(String password) {
this.password = password;
if (disconnectedMode) { return; }
// The password is stored in encrypted form for improved security.
String encryptedPassword = AuthFactory.encryptPassword(password);
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SET_PASSWORD);
if (password != null) {
pstmt.setString(1, encryptedPassword);
}
else {
pstmt.setNull(1, Types.VARCHAR);
}
pstmt.setLong(2, registrationID);
pstmt.executeUpdate();
}
catch (SQLException sqle) {
Log.error(sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
示例4: insertIntoDb
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
/**
* Inserts a new registration into the database.
*
* @throws SQLException if the SQL statement is wrong for whatever reason.
*/
private void insertIntoDb() throws SQLException {
if (disconnectedMode) { return; }
this.registrationID = SequenceManager.nextID(this);
Connection con = null;
PreparedStatement pstmt = null;
boolean abortTransaction = false;
try {
con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(INSERT_REGISTRATION);
pstmt.setLong(1, registrationID);
pstmt.setString(2, jid.toString());
pstmt.setString(3, transportType.name());
pstmt.setString(4, username);
if (password != null) {
// The password is stored in encrypted form for improved security.
String encryptedPassword = AuthFactory.encryptPassword(password);
pstmt.setString(5, encryptedPassword);
}
else {
pstmt.setNull(5, Types.VARCHAR);
}
if (nickname != null) {
pstmt.setString(6, nickname);
}
else {
pstmt.setNull(6, Types.VARCHAR);
}
pstmt.setLong(7, registrationDate.getTime());
pstmt.executeUpdate();
}
catch (SQLException sqle) {
abortTransaction = true;
throw sqle;
}
finally {
DbConnectionManager.closeTransactionConnection(pstmt, con, abortTransaction);
}
}
示例5: overwriteExistingRegistration
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
/**
* Overwrites an existing registration with updated information
*
* Note: Registration must be based on an existing registration for this to work.
*
* @param curReg Registration we are overwriting.
* @param newReg New registration info that will overwrite old.
* @throws SQLException is there was an error interacting with the database.
*/
public void overwriteExistingRegistration(Registration curReg, Registration newReg) throws SQLException {
Connection con = null;
PreparedStatement pstmt = null;
boolean abortTransaction = false;
try {
con = DbConnectionManager.getTransactionConnection();
pstmt = con.prepareStatement(UPDATE_REGISTRATION);
pstmt.setString(1, newReg.getJID().toString());
pstmt.setString(2, newReg.getTransportType().name());
pstmt.setString(3, newReg.getUsername());
if (newReg.getPassword() != null) {
// The password is stored in encrypted form for improved security.
String encryptedPassword = AuthFactory.encryptPassword(newReg.getPassword());
pstmt.setString(4, encryptedPassword);
}
else {
pstmt.setNull(4, Types.VARCHAR);
}
if (newReg.getNickname() != null) {
pstmt.setString(5, newReg.getNickname());
}
else {
pstmt.setNull(5, Types.VARCHAR);
}
pstmt.setLong(6, newReg.getRegistrationDate().getTime());
if (newReg.getLastLogin() != null) {
pstmt.setLong(7, newReg.getLastLogin().getTime());
}
else {
pstmt.setNull(7, Types.INTEGER);
}
pstmt.setLong(8, curReg.getRegistrationID());
pstmt.executeUpdate();
}
catch (SQLException sqle) {
abortTransaction = true;
throw sqle;
}
finally {
DbConnectionManager.closeTransactionConnection(pstmt, con, abortTransaction);
}
}
示例6: createUser
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
public User createUser(String username, String password, String name, String email)
throws UserAlreadyExistsException
{
try {
loadUser(username);
// The user already exists since no exception, so:
throw new UserAlreadyExistsException("Username " + username + " already exists");
}
catch (UserNotFoundException unfe) {
// The user doesn't already exist so we can create a new user
// Determine if the password should be stored as plain text or encrypted.
boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword");
String encryptedPassword = null;
if (!usePlainPassword) {
try {
encryptedPassword = AuthFactory.encryptPassword(password);
// Set password to null so that it's inserted that way.
password = null;
}
catch (UnsupportedOperationException uoe) {
// Encrypting the password may have failed if in setup mode. Therefore,
// use the plain password.
}
}
Date now = new Date();
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(INSERT_USER);
pstmt.setString(1, username);
if (password == null) {
pstmt.setNull(2, Types.VARCHAR);
}
else {
pstmt.setString(2, password);
}
if (encryptedPassword == null) {
pstmt.setNull(3, Types.VARCHAR);
}
else {
pstmt.setString(3, encryptedPassword);
}
if (name == null || name.matches("\\s*")) {
pstmt.setNull(4, Types.VARCHAR);
}
else {
pstmt.setString(4, name);
}
if (email == null || email.matches("\\s*")) {
pstmt.setNull(5, Types.VARCHAR);
}
else {
pstmt.setString(5, email);
}
pstmt.setString(6, StringUtils.dateToMillis(now));
pstmt.setString(7, StringUtils.dateToMillis(now));
pstmt.execute();
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
//create new G3Chat user with "empty city"
createG3ChatUser(username,"errrrrrrrrrrr","118.721854","32.129093",1);
return new User(username, name, email, now, now);
}
}
示例7: createUser
import org.jivesoftware.openfire.auth.AuthFactory; //导入方法依赖的package包/类
public User createUser(String username, String password, String name, String email)
throws UserAlreadyExistsException
{
try {
loadUser(username);
// The user already exists since no exception, so:
throw new UserAlreadyExistsException("Username " + username + " already exists");
}
catch (UserNotFoundException unfe) {
// The user doesn't already exist so we can create a new user
// Determine if the password should be stored as plain text or encrypted.
boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword");
String encryptedPassword = null;
if (!usePlainPassword) {
try {
encryptedPassword = AuthFactory.encryptPassword(password);
// Set password to null so that it's inserted that way.
password = null;
}
catch (UnsupportedOperationException uoe) {
// Encrypting the password may have failed if in setup mode. Therefore,
// use the plain password.
}
}
Date now = new Date();
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(INSERT_USER);
pstmt.setString(1, username);
if (password == null) {
pstmt.setNull(2, Types.VARCHAR);
}
else {
pstmt.setString(2, password);
}
if (encryptedPassword == null) {
pstmt.setNull(3, Types.VARCHAR);
}
else {
pstmt.setString(3, encryptedPassword);
}
if (name == null || name.matches("\\s*")) {
pstmt.setNull(4, Types.VARCHAR);
}
else {
pstmt.setString(4, name);
}
if (email == null || email.matches("\\s*")) {
pstmt.setNull(5, Types.VARCHAR);
}
else {
pstmt.setString(5, email);
}
pstmt.setString(6, StringUtils.dateToMillis(now));
pstmt.setString(7, StringUtils.dateToMillis(now));
pstmt.execute();
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
return new User(username, name, email, now, now);
}
}