Revolving around the core of technology
Document ID: | 3731 |
---|---|
Subject: | Extending user authentication mechanism in Syncrify |
Creation date: | 8/18/14 11:11 AM |
Last modified on: | 12/12/18 11:42 AM |
You will have to test and/or update your code whenever we release a new build. This means you will have to maintain a development environment for Syncrify Server on your end from now on.
Install Syncrify Server on the same machine where Eclipse is also running.
Create a new project and include SyncrifyServer.jar in your project. This file is found in $INSTALL_DIR\lib\ folder of Syncrify.
You need to create a new class that implementscom.synametrics.syncrify.users.UserManager
interface. This interface is part of SyncrifyServer.jar and therefore, you should not get any compilation errors. In additional to UserManager, this interface refers to a couple of other classes. These classes are also part of SyncrifyServer.jar.
For reference, the code forcom.synametrics.syncrify.users.UserManager
interface is displayed below.
Obviously, you will have to write every method since you are implementing an interface. However, depending upon how the data is stored, you can leave the method's body empty. For example, there is no need to write a body forreload
andsave
methods if you are reading/writing from a relational database. This is because the SELECT and INSERT statements in your code will already take care of reading and saving the data.
Similarly, writing a body foraddUserProfile
method is optional. This method is used to let your code know a new profile was discovered. Your code is not required to take any action when this event occurs.
Once you are done implementing the interface, bundle all of your files into a JAR file. Place this newly created JAR file in $INSTALL_DIR\libs folder.
Then, locate $INSTALL_DIR\config\AppConfig.xml file and add the following parameter.
<parameter name="CustomUserManagerClass" type="1" value="com.yourcompany.YourClass"></parameter>
Finally, reinstall the service. This is done by running the following program from Command Prompt (DOS Window):
cd \Syncrify InstallService -uninstallService InstallService -installServiceNOTE: You only need to uninstall/install the service once. This step is not required when you update the JAR file on subsequent builds.
package com.synametrics.syncrify.users; import java.util.List; import java.util.Set; import com.synametrics.syncrify.bean.UserBean; public interface UserManager { /** * This method is called when a new user needs to be added. The implementing class should update its memory contents * with this new user. * @param oneUserHolder A new user holder that is being added. */ void addUser(DefaultUserHolder oneUserHolder); /** * This method should add a new profile if it does not exist or modify an existing one if it is found. * A profile is uniquely identified by user's login id and profile name. The purpose of this method is to let the * implementing class know a new profile is being added or modified. It can * chose not to take any action when this method is called. * * @param userLogin User name, which is typically an email address * @param aProfile Profile that is being added. */ void addUserProfile(String userLogin, String aProfile); /** * Returns the User Holder object for the given email. * @param login Email address, which serves as a login ID * @param password If this is null, Holder is returned by matching login alone. If this is provided, a match is found * based on user id and password * * @return Method should return null if a matching user is NOT found. */ DefaultUserHolder fetchUserHolder(String login, String password); /** * Returns a list of file paths that are used for user repository. This information is used to check the hard-disk space * for the user repositories. * @return Returns a set of repository paths */ Set<String> getAllRepositories(); /** * Returns a list of all users. * @return Returns a list of users in the system. */ List<UserBean> getAllUsers(); /** * Returns the total number of users in the system. * @return Total number of users */ int getTotalUserCount(); /** * Checks if the user is valid. * @param userId User ID * @param password Password * @param ipAddress IP address of the client. If this is null, only user id and password will be checked. * @return true if the user is valid. */ boolean isUserValid(String userId, String password, String ipAddress); /** * This method is called when the given user is modified * @param oneUserHolder */ void modifyUser(DefaultUserHolder oneUserHolder); /** * Reloads the user list from the persistent storage */ void reload(); /** * Gets called when a user should be removed from the system. * @param email */ void removeUser(String email); /** * This method is invoked when contents for memory should be saved to disk. The implementing class may decide to ignore * calls to this method. This happens when user repository resides in an RDBMS * @return true if data as saved. If the implementation class does not have to save anything, it should return true. A false * should be returned in case of an error. */ boolean save(); /** * This method is called when disk usage should be updated for the given user * @param email * @param diskUsage */ void setDiskUsage(String email, long diskUsage); }
Do you have a helpful tip related to this document that you'd like to share with other users?