Java Code Examples for org.nutz.lang.Strings

The following examples show how to use org.nutz.lang.Strings. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: web-flash   Source File: Utils.java    License: MIT License 6 votes vote down vote up
/**
 * 以“_”分割的单词转换为首字母大写驼峰格式
 * @param src
 * @return
 */
public static String upperCamel(String src){
    if(!src.contains("_")){
        return src;
    }
    src = src.toLowerCase();
    StringBuilder result = new StringBuilder();
    for(String sitem:src.split("_")){
        if(result.toString().length()==0){
            result.append(Strings.upperFirst(sitem));
        }else{
            result.append(Strings.upperFirst(sitem));
        }
    }
    return result.toString();
}
 
Example 2
Source Project: nutzcloud   Source File: LoachClient.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean _ping() {
    try {
        String pingURL = url + "/ping/" + getServiceName() + "/" + id;
        if (isDebug())
            log.debug("Ping URL=" + pingURL);
        Request req = Request.create(pingURL, METHOD.GET);
        req.getHeader().clear();
        req.getHeader().set("If-None-Match", lastPingETag);
        Response resp = Sender.create(req, conf.getInt("loach.client.ping.timeout", 1000)).setConnTimeout(1000).send();
        String cnt = resp.getContent();
        if (isDebug())
            log.debug("Ping result : " + cnt);
        if (resp.isOK()) {
            lastPingETag = Strings.sBlank(resp.getHeader().get("ETag"), "ABC");
            NutMap re = Json.fromJson(NutMap.class, cnt);
            if (re != null && re.getBoolean("ok", false))
                return true;
        } else if (resp.getStatus() == 304) {
            return true;
        }
    }
    catch (Throwable e) {
        log.debugf("bad url? %s %s", url, e.getMessage());
    }
    return false;
}
 
Example 3
Source Project: NutzSite   Source File: DeptServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据树
 * @param parentId
 * @param name
 * @return
 */
@Override
public List<Map<String, Object>> selectTree(String parentId, String name) {
    Cnd cnd = Cnd.NEW();
    if (Strings.isNotBlank(name)) {
        cnd.and("dept_name", "like", "%" + name + "%");
    }
    if (Strings.isNotBlank(parentId)) {
        cnd.and("parent_id", "=", parentId);
    }
    cnd.and("status", "=", false).and("del_flag", "=", false);
    List<Dept> deptList = this.query(cnd);
    List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
    trees = getTrees(deptList);
    return trees;
}
 
Example 4
Source Project: NutzSite   Source File: DeptServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkDeptNameUnique(String id, String parentId, String menuName) {
    Cnd cnd =Cnd.NEW();
    if(Strings.isNotBlank(id)){
        cnd.and("id","!=",id);
    }
    if(Strings.isNotBlank(parentId)){
        cnd.and("parent_id","=",parentId);
    }
    if(Strings.isNotBlank(menuName)){
        cnd.and("dept_name", "=", menuName);
    }
    List<Dept> list = this.query(cnd);
    if (Lang.isEmpty(list)) {
        return true;
    }
    return false;
}
 
Example 5
Source Project: NutzSite   Source File: UserServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 更新角色
 *
 * @param data
 */
@Override
public void updataRelation(User data) {
    List<String> ids = new ArrayList<>();
    if (data != null && Strings.isNotBlank(data.getRoleIds())) {
        if (Strings.isNotBlank(data.getRoleIds())) {
            ids = Arrays.asList(data.getRoleIds().split(","));
        }
        //清除已有关系
        User tmpData = this.fetch(data.getId());
        this.fetchLinks(tmpData, "roles");
        dao().clearLinks(tmpData, "roles");
    }
    if (ids != null && ids.size() > 0) {
        Criteria cri = Cnd.cri();
        cri.where().andInStrList("id", ids);
        List<Role> roleList = roleService.query(cri);
        data.setRoles(roleList);
    }
    //更新关系
    dao().insertRelation(data, "roles");
}
 
Example 6
Source Project: NutzSite   Source File: RoleServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 更新角色
 *
 * @param data
 * @return
 */
@Override
public int update(Role data) {
    List<String> ids = new ArrayList<>();
    if (data != null && data.getMenuIds() != null) {
        if (Strings.isNotBlank(data.getMenuIds())) {
            ids = Arrays.asList(data.getMenuIds().split(","));
        }
        //清除已有关系
        Role tmpData = this.fetch(data.getId());
        this.fetchLinks(tmpData, "menus");
        dao().clearLinks(tmpData, "menus");
    }
    if (ids != null && ids.size() > 0) {
        Criteria cri = Cnd.cri();
        cri.where().andInStrList("id", ids);
        List<Menu> menuList = menuService.query(cri);
        data.setMenus(menuList);
    }
    int count = dao().update(data);
    dao().insertRelation(data, "menus");
    return count;
}
 
Example 7
Source Project: NutzSite   Source File: RoleServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 校验角色名称是否唯一
 * @param roleName
 * @return
 */
@Override
public boolean checkRoleNameUnique(String id, String roleName, String roleKey) {
    Cnd cnd =Cnd.NEW();
    if(Strings.isNotBlank(id)){
        cnd.and("id","!=",id);
    }
    if(Strings.isNotBlank(roleName)){
        cnd.and("role_name", "=", roleName);
    }
    if(Strings.isNotBlank(roleKey)){
        cnd.and("role_key", "=", roleKey);
    }
    List<Role> roleList = this.query(cnd);
    if (Lang.isEmpty(roleList)) {
        return true;
    }
    return false;
}
 
Example 8
Source Project: NutzSite   Source File: AreaServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
	 * 查询数据树
	 * @param parentId
	 * @param name
	 * @return
	 */
	@Override
    public List<Map<String, Object>> selectTree(String parentId, String name) {
		Cnd cnd = Cnd.NEW();
		if (Strings.isNotBlank(name)) {
			//cnd.and("name", "like", "%" + name + "%");
		}
		if (Strings.isNotBlank(parentId)) {
			cnd.and("parent_id", "=", parentId);
		}
//		cnd.and("status", "=", false).and("del_flag", "=", false);
		List<Area> list = this.query(cnd);
		List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
		trees = getTrees(list);
		return trees;
	}
 
Example 9
Source Project: NutzSite   Source File: ProfileController.java    License: Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@Slog(tag="个人信息", after="重置密码")
public Result resetPwdDo(@Param("oldPassword") String oldPassword,
                       @Param("newPassword") String newPassword) {
    User user = ShiroUtils.getSysUser();
    String old = new Sha256Hash(oldPassword, user.getSalt(), 1024).toBase64();
    if (Strings.isNotBlank(newPassword) && old.equals(user.getPassword())) {
        user.setPassword(newPassword);
        if (userService.resetUserPwd(user) > 0) {
            ShiroUtils.setSysUser(userService.fetch(user.getId()));
            return Result.success("system.success");
        }
        return Result.error("system.error");
    } else {
        return Result.error("profile.resetpwd");
    }
}
 
Example 10
Source Project: NutzSite   Source File: DictController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询字典列表
 */
@RequiresPermissions("sys:dict:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
       cnd.and("del_flag","=",false);
	return dictService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 11
Source Project: NutzSite   Source File: MenuController.java    License: Apache License 2.0 6 votes vote down vote up
@At
@POST
@Ok("json")
@RequiresPermissions("sys:menu:edit")
@Slog(tag="菜单", after="修改保存菜单")
public Object editDo(@Param("..") Menu menu, @Param("parentId") String parentId, Errors es, HttpServletRequest req) {
    try {
        if(es.hasError()){
             return Result.error(es);
        }
        if (menu != null && Strings.isEmpty(menu.getParentId())) {
            menu.setParentId("0");
        }
        if(Lang.isNotEmpty(menu)){
            menu.setUpdateBy(ShiroUtils.getSysUserId());
            menu.setUpdateTime(new Date());
            menuService.update(menu);
        }
        return Result.success("system.success");
    } catch (Exception e) {
        return Result.error(e instanceof ErrorException ? e.getMessage() : "system.error");
    }
}
 
Example 12
Source Project: mpsdk4j   Source File: WechatAPIImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Follower getWebOauth2User(String openId, String lang) {
    lang = Strings.sBlank(lang, "zh_CN");
    WebOauth2Result result = _oath2.get(openId);
    if (result == null){
       throw Lang.wrapThrow(new WechatAPIException("用户未授权"));
    } else if (!result.isAvailable()){
        result = refreshWebOauth2Result(result.getRefreshToken());
    }

    String url = mergeAPIUrl(oauth2UserURL, result.getAccessToken(), openId, lang);
    APIResult ar = wechatServerResponse(url,
            HTTP_GET,
            NONE_BODY,
            "以网页授权方式获取公众号[%s]的用户[%s-%s]信息失败.",
            openId,
            lang);
    return Json.fromJson(Follower.class, ar.getJson());
}
 
Example 13
Source Project: DAFramework   Source File: OAuth2Util.java    License: MIT License 6 votes vote down vote up
public static EAccessToken fetch(OAuth2Authentication oAuth2Authentication, OAuth2AccessToken accessToken){
	EAccessToken eAccessToken = new EAccessToken();
	eAccessToken.setOpenUser(fetch(oAuth2Authentication));

	Object details = oAuth2Authentication.getDetails();
	if(details instanceof OAuth2AuthenticationDetails){
		OAuth2AuthenticationDetails details1 = (OAuth2AuthenticationDetails) details;
		eAccessToken.setRemoteAddress(details1.getRemoteAddress());
		eAccessToken.setSessionId(details1.getSessionId());
	}
	eAccessToken.setTokenType(accessToken.getTokenType());
	eAccessToken.setTokenValue(accessToken.getValue());
	eAccessToken.setExpiresIn(accessToken.getExpiresIn());
	if (accessToken.getRefreshToken() != null) {
		eAccessToken.setRefreshToken(accessToken.getRefreshToken().getValue());
	}
	if (accessToken.getScope() != null) {
		String scopes = Strings.join2("|", accessToken.getScope().toArray(new String[]{}));
		eAccessToken.setScopes(scopes);
	}
	return eAccessToken;
}
 
Example 14
Source Project: NutzSite   Source File: RoleController.java    License: Apache License 2.0 6 votes vote down vote up
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
                   @Param("pageSize")Integer pageSize,
                   @Param("roleName") String roleName,
                   @Param("roleKey") String roleKey,
                   @Param("orderByColumn") String orderByColumn,
                   @Param("isAsc") String isAsc,
                   HttpServletRequest req) {
    Cnd cnd = Cnd.NEW();
    if (!Strings.isBlank(roleName)){
        cnd.and("role_name", "like", "%" + roleName +"%");
    }
    if (!Strings.isBlank(roleKey)){
        cnd.and("role_key", "=", roleKey);
    }
    return roleService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 15
Source Project: NutzSite   Source File: MaterialController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询微信素材列表
 */
@RequiresPermissions("wx:material:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return materialService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 16
Source Project: NutzSite   Source File: WxMenuController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询微信菜单列表
 */
@At
@Ok("json")
@RequiresPermissions("wx:menu:list")
public Object list(@Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return wxMenuService.query(cnd);
}
 
Example 17
Source Project: NutzSite   Source File: WxMenuServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据树
 * @param parentId
 * @param name
 * @return
 */
@Override
public List<Map<String, Object>> selectTree(String parentId, String name) {
	Cnd cnd = Cnd.NEW();
	if (Strings.isNotBlank(name)) {
		//cnd.and("name", "like", "%" + name + "%");
	}
	if (Strings.isNotBlank(parentId)) {
		cnd.and("parent_id", "=", parentId);
	}
	//cnd.and("status", "=", false).and("del_flag", "=", false);
	List<WxMenu> list = this.query(cnd);
	List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
	trees = getTrees(list);
	return trees;
}
 
Example 18
Source Project: NutzSite   Source File: SiteController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询站点列表
 */
@RequiresPermissions("cms:site:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return siteService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 19
Source Project: NutzSite   Source File: CategoryController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询栏目列表
 */
@At
@Ok("json")
@RequiresPermissions("cms:category:list")
public Object list(@Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	cnd.asc("sort");
	return categoryService.query(cnd);
}
 
Example 20
Source Project: NutzSite   Source File: CategoryServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询数据树
 * @param parentId
 * @param name
 * @return
 */
@Override
   public List<Map<String, Object>> selectTree(String parentId, String name) {
	Cnd cnd = Cnd.NEW();
	if (Strings.isNotBlank(name)) {
		//cnd.and("name", "like", "%" + name + "%");
	}
	if (Strings.isNotBlank(parentId)) {
		cnd.and("parent_id", "=", parentId);
	}
	//cnd.and("status", "=", false).and("del_flag", "=", false);
	cnd.asc("sort");
	List<Category> list = this.query(cnd);
	List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
	trees = getTrees(list);
	return trees;
}
 
Example 21
Source Project: NutzSite   Source File: PetController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询宠物列表
 */
@RequiresPermissions("test:pet:list")
@At
@Ok("json")
public Object list(@Param("pageNum")int pageNum,
				   @Param("pageSize")int pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return petService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,"master");
}
 
Example 22
Source Project: NutzSite   Source File: MasterController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询主人列表
 */
@RequiresPermissions("test:master:list")
@At
@Ok("json")
public Object list(@Param("pageNum")int pageNum,
				   @Param("pageSize")int pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return masterService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 23
Source Project: NutzSite   Source File: UserOnlineController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 查询在线用户记录列表
 */
@RequiresPermissions("monitor:online:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String ipaddr,
				   @Param("loginName") String loginName,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(ipaddr)){
		cnd.and("ipaddr", "=", ipaddr);
	}
	if (!Strings.isBlank(loginName)){
		cnd.and("login_name", "=", loginName);
	}
	return userOnlineService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 24
Source Project: NutzSite   Source File: Globals.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 获取上传文件的根目录
 *
 * @return
 */
public static String getUserfilesBaseDir() {
    String dir = getConfig("userfiles.basedir");
    if (Strings.isBlank(dir)) {
        try {
            dir = Mvcs.getServletContext().getRealPath("/");
        } catch (Exception e) {
            return "";
        }
    }
    if (!dir.endsWith("/")) {
        dir += "/";
    }
    // System.out.println("userfiles.basedir: " + dir);
    return dir;
}
 
Example 25
Source Project: NutzSite   Source File: GlobalsSettingProcessor.java    License: Apache License 2.0 6 votes vote down vote up
@Override
    public void process(ActionContext ac) throws Throwable {

        boolean captcha = Boolean.valueOf(Globals.getConfig("login.captcha"));
        String path = ac.getServletContext().getContextPath();
        String projectName = path.length() > 0 ? path + "/" : "/";
        ac.getRequest().setAttribute("AppBase", projectName);
        ac.getRequest().setAttribute("captchaEnabled", captcha);
        ac.getRequest().setAttribute("pubkey", Globals.getPublicKey());
//      //允许跨越
//        ac.getResponse().addHeader("Access-Control-Allow-Origin", "*");
//        ac.getResponse().addHeader("Access-Control-Allow-Credentials", "true");
//        ac.getResponse().addHeader("Access-Control-Allow-Headers",
//                "Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie");
        // 如果url中有语言属性则设置
        String lang = ac.getRequest().getParameter("lang");
        if (!Strings.isEmpty(lang)) {
            Mvcs.setLocalizationKey(lang);
        } else {
            // Mvcs.getLocalizationKey()  1.r.56 版本是null,所以要做两次判断, 1.r.57已修复为默认值 Nutz:Fix issue 1072
            lang = Strings.isBlank(Mvcs.getLocalizationKey()) ? Mvcs.getDefaultLocalizationKey() : Mvcs.getLocalizationKey();
        }
        ac.getRequest().setAttribute("lang", lang);
        doNext(ac);
    }
 
Example 26
Source Project: NutzSite   Source File: BaseServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public QueryResult listPage(int pageNumber, int pageSize, Cnd cnd, String orderByColumn, String isAsc, String linkname){
    Pager pager = this.dao().createPager(pageNumber, pageSize);
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    pager.setRecordCount(this.dao().count(getEntityClass(), cnd));
    return new QueryResult(list, pager);
}
 
Example 27
Source Project: NutzSite   Source File: BaseServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
public TableDataInfo tableListFetchLinks(Integer pageNumber, Integer pageSize,Cnd cnd,String orderByColumn,String isAsc,String linkname){
    Pager pager=null;
    if(Lang.isNotEmpty(pageNumber) && Lang.isNotEmpty(pageSize)){
        pager = this.dao().createPager(pageNumber, pageSize);
    }
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    return new TableDataInfo(list, this.dao().count(this.getEntityClass(),cnd));
}
 
Example 28
Source Project: NutzSite   Source File: SimpleAuthorizingRealm.java    License: Apache License 2.0 6 votes vote down vote up
@Override
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
		UsernamePasswordToken upToken = (UsernamePasswordToken) token;
		if (Lang.isEmpty(upToken) || Strings.isEmpty(upToken.getUsername())) {
			throw Lang.makeThrow(AuthenticationException.class, "Account name is empty");
		}
		User user = userService.fetch(Cnd.where("login_name","=",upToken.getUsername()));
		if (Lang.isEmpty(user)) {
			throw Lang.makeThrow(UnknownAccountException.class, "Account [ %s ] not found", upToken.getUsername());
		}
		if (user.isStatus()) {
			throw Lang.makeThrow(LockedAccountException.class, "Account [ %s ] is locked.", upToken.getUsername());
		}
		SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user,
				user.getPassword().toCharArray(), ByteSource.Util.bytes(user.getSalt()), getName());
		info.setCredentialsSalt(ByteSource.Util.bytes(user.getSalt()));
//        info.
		return info;
	}
 
Example 29
Source Project: NutzSite   Source File: XssHttpServletRequestWrapper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 覆盖getParameter方法,将参数名和参数值都做xss过滤。<br/>
 * 如果需要获得原始的值,则通过super.getParameterValues(name)来获取<br/>
 * getParameterNames,getParameterValues和getParameterMap也可能需要覆盖
 */
@Override
public String getParameter(String name) {
    if(("content".equals(name) || name.endsWith("WithHtml")) && !isIncludeRichText){
        return super.getParameter(name);
    }
    name = JsoupUtil.clean(name);
    String value = super.getParameter(name);
    if (Strings.isNotBlank(value)) {
        // HTML transformation characters
        value = JsoupUtil.clean(value);
        // SQL injection characters
        value = StringEscapeUtils.escapeSql(value);
    }
    return value;
}
 
Example 30
Source Project: nutzwx   Source File: Wxs.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 根据提交参数,生成签名
 *
 * @param map
 *            要签名的集合
 * @param key
 *            商户秘钥
 * @return 签名
 *
 * @see <a href=
 *      "https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3">
 *      微信商户平台签名算法</a>
 *
 */
public static String genPaySign(Map<String, Object> map, String key, String signType) {
    String[] nms = map.keySet().toArray(new String[map.size()]);
    Arrays.sort(nms);
    StringBuilder sb = new StringBuilder();
    signType = signType == null ? "MD5" : signType.toUpperCase();
    boolean isMD5 = "MD5".equals(signType);
    for (String nm : nms) {
        Object v = map.get(nm);
        if (null == v)
            continue;
        // JSSDK 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。
        // 但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
        if (isMD5 && "timestamp".equals(nm)) {
            nm = "timeStamp";
        }
        String s = v.toString();
        if (Strings.isBlank(s))
            continue;
        sb.append(nm).append('=').append(s).append('&');
    }
    sb.append("key=").append(key);
    return Lang.digest(signType, sb).toUpperCase();
}