Shortcut Access Function¶
Topics
About Shortcut Access Function¶
Shortcut access function is the function to switch the screen after log-in to any screen by specifying shortcut access URL to the initial access URL.By using the shortcut access function, you can display any page you want from the screen after log-in.
Shortcut Access URL¶
URL for shortcut access will be the URL below which includes shortcut ID.http:// <server> / <context-path> /user/shortcut/ <shortcut ID><Description Example>http://localhost/imart/user/shortcut/5i4deh98wou5uuc
Shortcut ID Creation¶
Shortcut ID is the ID associated with the information of the page to be displayed and the security information.Shortcut ID is created using the API by specifying information of the page to be displayed and the security information.Creation steps of shortcut ID for specifying /sample/shortcut on the screen displayed after log-in will be described below.// Create shortcut manager ShortCutManager manager = new ShortCutManager(); // Create shortcut information ShortCutInfo shortCutInfo = new ShortCutInfo(); // Display URL shortCutInfo.setUrl("/sample/shortcut"); // Setting of parameters passed to URL to be displayed (optionl setting) shortCutInfo.setUrlParam("arg1","value1"); shortCutInfo.setUrlParam("arg2","value2"); // Users for whom display is permitted shortCutInfo.setAllowsUsers(new String[]{"guest","ueda"}); // Is login authentication required ? shortCutInfo.setAuth(true); // Validity expiration of this information (valid for 10 days after creation) shortCutInfo.setValidEndDate(manager.addValidEndDate(10)); // Create shortcut ID String shortCutId = manager.createShortCut(shortCutInfo);
Shortcut Extension Verification Function¶
Extension verification function is the function to judge if the page display permission should be given to the log-in users other thanthe permitted users for displaying shortcut URL by utilizing the verification function.Extension verification code represents the code name of the verification program.Extension verification parameters are the parameters passed to the verification program.// Create shortcut manager ShortCutManager manager = new ShortCutManager(); // Create shortcut information ShortCutInfo shortCutInfo = new ShortCutInfo(); // URL to be displayed shortCutInfo.setUrl("/sample/shortcut"); // Setting of parameters passed to URL to be displayed (optional setting) shortCutInfo.setUrlParam("arg1","value1"); shortCutInfo.setUrlParam("arg2","value2"); // Users for whom display is permitted (Setting is not required if only the validation function is used.) shortCutInfo.setAllowsUsers(new String[]{"guest","ueda"}); // Is login authentication required ? (It will be true regardless of the setting value, if the validation function is used.) shortCutInfo.setAuth(true); // Validity expiration of this information (valid for 10 days after creation) shortCutInfo.setValidEndDate(manager.addValidEndDate(10)); shortCutInfo.setValidationCode("RoleUser"); // Validation code to check if additional user is permitted shortCutInfo.setValidationParam(""); //Additional parameters to be passed to validation process // Create shortcut ID String shortCutId = manager.createShortCut(shortCutInfo);
Verification Program Creation¶
Verification program is created by implementing jp.co.intra_mart.foundation.security.shortcut.ShortCutValidator.Method to be implemented: boolean isAllowUser(String groupId, ShortCutInfo shortcutInfo, String userId) throws AccessSecurityExceptionIn case this method is true, it is a permitted user.package jp.co.intra_mart.foundation.security.shortcut; import java.util.regex.Pattern; import jp.co.intra_mart.foundation.security.exception.AccessSecurityException; /** * Shortcut verification class which validates permitted users by regular expression. <br> * <br> * Specified as extension validation parameter of shortcut information<br> * Permission is given if regular expression and user name match. * @author INTRAMART * @version 8.0 * @since 7.0 */ public class RegExpUserShortCutValidator implements ShortCutValidator { /** * Judges if the regular expression specified in the extension validation parameter of shortcut information matches with the user ID.<br> * @param groupId Login group ID * @param shortcutInfo Shortcut information * @param userId User ID * @return It is true for permitted user. * @throws It is thrown if error has occurred while validating AccessSecurityException. */ @Override public boolean isAllowUser(final String groupId, final ShortCutInfo shortcutInfo, final String userId) throws AccessSecurityException { return Pattern.matches(shortcutInfo.getValidationParam(), userId); } }
Verification Code and Verification Program Setting¶
Add the following settings to the shortcut access setting (short-cut-config.xml) from IM-Juggling.Add <validator>.
Verification code is set to the attribute code.
Verification program class is set to the attribute class.
<?xml version="1.0" encoding="UTF-8"?> <short-cut-config> <short-cut-accessor> <short-cut-accessor-class>jp.co.intra_mart.foundation.security.shortcut.StandardShortCutAccessor</short-cut-accessor-class> <error-page>/user/shortcut/error</error-page> <main-page>/home</main-page> <validator code="RegExpUser" class="jp.co.intra_mart.foundation.security.shortcut.RegExpUserShortCutValidator"/> <validator code="RoleUser" class="jp.co.intra_mart.foundation.security.shortcut.RoleUserShortCutValidator"/> <validator code="Script" class="jp.co.intra_mart.foundation.security.shortcut.ScriptShortCutValidator"/> <validator code="sample" class="jp.co.intra_mart.foundation.security.shortcut.SampleValidator"/> </short-cut-accessor> </short-cut-config>Warning
intra-mart Accel Platfom 2013 Autumn or after would be required to edit shortcut access setting (short-cut-config.xml) by IM-Juggling.If the version is before intra-mart Accel Platfom 2013 Autumn, please directly edit the created war file.
About Standard Verification Code¶
3 types of verification codes are registered as standard.
User of the user ID that matches with the regular expression specified by the extension verification parameter will become the permitted user.
Verification Code
Verification Program
RegExpUser
jp.co.intra_mart.foundation.security.shortcut.RegExpUserShortCutValidator
User who has the role ID specified by the extension verification parameter will become the permitted user.
Verification Code
Verification Program
RoleUser
jp.co.intra_mart.foundation.security.shortcut.RoleUserShortCutValidator
Execute the script and verify the permitted user.
Verification Code
Verification Program
Script
jp.co.intra_mart.foundation.security.shortcut.ScriptShortCutValidator
It is judged by the isAllowUser method of script which is specified in the extension verification parameter of shortcut information.When this module is used, the path of the script is specified in the extension verification parameter of shortcut information.No extension is attached.example: shortcut/validatorIn case you want to pass the parameter (param) to the isAllowUser method of script, parameter is specifiedafter the path of script of extension verification prameter of shortcut information following the comma delimiter.example: shortcut/validator,parameter valueIn case parameter value has not been specified, blank character string is passed to the param argument of isAllowUser method of script.isAllowUser method interface of scriptBoolean isAllowUser(String groupId, ShortCutInfo shortcutInfo,String userId,String param)