org.apache.commons.lang3.StringUtils#isAllBlank ( )源码实例Demo

下面列出了org.apache.commons.lang3.StringUtils#isAllBlank ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SpringBlade   文件: AuthFilter.java
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
	String path = exchange.getRequest().getURI().getPath();
	if (isSkip(path)) {
		return chain.filter(exchange);
	}
	ServerHttpResponse resp = exchange.getResponse();
	String headerToken = exchange.getRequest().getHeaders().getFirst(AuthProvider.AUTH_KEY);
	String paramToken = exchange.getRequest().getQueryParams().getFirst(AuthProvider.AUTH_KEY);
	if (StringUtils.isAllBlank(headerToken, paramToken)) {
		return unAuth(resp, "缺失令牌,鉴权失败");
	}
	String auth = StringUtils.isBlank(headerToken) ? paramToken : headerToken;
	String token = JwtUtil.getToken(auth);
	Claims claims = JwtUtil.parseJWT(token);
	if (claims == null) {
		return unAuth(resp, "请求未授权");
	}
	return chain.filter(exchange);
}
 
源代码2 项目: redtorch   文件: NodeServiceImpl.java
@Override
public NodePo nodeAuth(NodePo node) {
	if (node == null) {
		logger.error("节点审核错误,参数node缺失");
		throw new IllegalArgumentException("节点审核错误,参数node缺失");
	}
	if (node.getNodeId() == null) {
		logger.error("节点审核错误,参数nodeId缺失");
		throw new IllegalArgumentException("节点审核错误,参数nodeId缺失");
	}
	if (StringUtils.isAllBlank(node.getToken())) {
		logger.error("节点审核错误,参数token缺失");
		throw new IllegalArgumentException("节点审核错误,参数token缺失");
	}

	NodePo queriedNode = nodeDao.queryNodeByNodeId(node.getNodeId());
	if (queriedNode != null && node.getToken().equals(queriedNode.getToken())) {
		logger.info("节点审核成功,节点ID:{}", node.getNodeId());
		return queriedNode;
	} else {
		logger.info("节点审核失败,节点ID:{}", node.getNodeId());
		return null;
	}
}
 
源代码3 项目: jakduk-api   文件: UserService.java
/**
 * SNS 회원의 하위 호환 검사
 *
 * @param snsEmail Provider(페이스북, 다음)에서 가져온 email
 * @param user DB에서 가져온 회원
 */
public void checkBackwardCompatibilityOfSnsUser(String snsEmail, User user) {

	// User DB 와 SNS Profile 모두에 email이 없을 경우에는 신규 가입으로 진행한다.
	// SNS 가입시 이메일 제공 동의를 안해서 그렇다.
	if (StringUtils.isAllBlank(user.getEmail(), snsEmail)) {
		user.setEmail(JakdukUtils.generateTemporaryEmail());
		userRepository.save(user);

		log.info("user({},{}) temporary email:{} has been entered.", user.getId(), user.getUsername(), user.getEmail());
	}
	// 과거 SNS 가입 회원들은 email이 없는 경우가 있음. 이메일을 DB에 저장
	else if (StringUtils.isBlank(user.getEmail()) && StringUtils.isNotBlank(snsEmail)) {
		user.setEmail(snsEmail);
		userRepository.save(user);

		log.info("user({},{}) email:{} has been entered.", user.getId(), user.getUsername(), user.getEmail());
	}
}
 
源代码4 项目: prebid-server-java   文件: AmpRequestFactory.java
/**
 * Extracts parameters from http request and overrides corresponding attributes in {@link BidRequest}.
 */
private BidRequest overrideParameters(BidRequest bidRequest, HttpServerRequest request) {
    final String requestConsentParam = request.getParam(CONSENT_PARAM);
    final String requestGdprConsentParam = request.getParam(GDPR_CONSENT_PARAM);
    final String consentString = ObjectUtils.firstNonNull(requestConsentParam, requestGdprConsentParam);

    String gdprConsent = null;
    String ccpaConsent = null;
    if (StringUtils.isNotBlank(consentString)) {
        gdprConsent = TcfDefinerService.isGdprConsentValid(consentString) ? consentString : null;
        ccpaConsent = Ccpa.isValid(consentString) ? consentString : null;

        if (StringUtils.isAllBlank(gdprConsent, ccpaConsent)) {
            logger.debug("Amp request parameter consent_string or gdpr_consent have invalid format: {0}",
                    consentString);
        }
    }

    final Site updatedSite = overrideSite(bidRequest.getSite(), request);
    final Imp updatedImp = overrideImp(bidRequest.getImp().get(0), request);
    final Long updatedTimeout = overrideTimeout(bidRequest.getTmax(), request);
    final User updatedUser = overrideUser(bidRequest.getUser(), gdprConsent);
    final Regs updatedRegs = overrideRegs(bidRequest.getRegs(), ccpaConsent);

    final BidRequest result;
    if (updatedSite != null || updatedImp != null || updatedTimeout != null || updatedUser != null
            || updatedRegs != null) {
        result = bidRequest.toBuilder()
                .site(updatedSite != null ? updatedSite : bidRequest.getSite())
                .imp(updatedImp != null ? Collections.singletonList(updatedImp) : bidRequest.getImp())
                .tmax(updatedTimeout != null ? updatedTimeout : bidRequest.getTmax())
                .user(updatedUser != null ? updatedUser : bidRequest.getUser())
                .regs(updatedRegs != null ? updatedRegs : bidRequest.getRegs())
                .build();
    } else {
        result = bidRequest;
    }
    return result;
}
 
源代码5 项目: redtorch   文件: SystemController.java
@RequestMapping(value = { "/changePassword" }, method = { RequestMethod.POST })
@ResponseBody
public ResponseVo<UserPo> changePassword(HttpServletRequest request, @RequestBody UserPo user) {
	ResponseVo<UserPo> responseVo = new ResponseVo<>();
	try {
		if (user == null) {
			responseVo.setStatus(false);
			responseVo.setMessage("修改密码失败,未找到请求体");
		} else {
			if (request.getSession().getAttribute(RtConstant.KEY_USER_PO) != null) {
				UserPo sessionUser = (UserPo) request.getSession().getAttribute(RtConstant.KEY_USER_PO);
				logger.info("用户{}修改密码,地址{}:{}", sessionUser.getUsername(), request.getRemoteAddr(), request.getRemotePort());
				if ("admin".equals(sessionUser.getUsername())) {
					responseVo.setStatus(false);
					responseVo.setMessage("修改密码失败,admin用户仅允许通过配置文件修改密码");
					return responseVo;
				} else {
					user.setUsername(sessionUser.getUsername());
					String resString = userService.userChangePassword(user);
					if (!StringUtils.isAllBlank(resString)) {
						responseVo.setStatus(false);
						responseVo.setMessage(resString);
					}
				}
			} else {
				responseVo.setStatus(false);
				responseVo.setMessage("修改密码失败,SESSION缓存中未能找到用户");
			}
		}
	} catch (Exception e) {
		logger.error("修改密码异常", e);
		responseVo.setStatus(false);
		responseVo.setMessage(e.getMessage());
	}
	return responseVo;
}
 
源代码6 项目: redtorch   文件: UserController.java
@RequestMapping(value = { "/changePassword" }, method = { RequestMethod.POST })
@ResponseBody
public ResponseVo<UserPo> changePassword(HttpServletRequest request, @RequestBody UserPo user) {
	ResponseVo<UserPo> responseVo = new ResponseVo<>();
	try {
		if (user == null) {
			responseVo.setStatus(false);
			responseVo.setMessage("修改密码失败,未找到请求体");
		} else {
			if (request.getSession().getAttribute(RtConstant.KEY_USER_PO) != null) {
				UserPo sessionUser = (UserPo) request.getSession().getAttribute(RtConstant.KEY_USER_PO);
				logger.info("用户{}修改密码,地址{}:{}", sessionUser.getUsername(), request.getRemoteAddr(), request.getRemotePort());
				if ("admin".equals(sessionUser.getUsername())) {
					responseVo.setStatus(false);
					responseVo.setMessage("修改密码失败,admin用户仅允许通过配置文件修改密码");
					return responseVo;
				} else {
					user.setUsername(sessionUser.getUsername());
					String resString = userService.userChangePassword(user);
					if (!StringUtils.isAllBlank(resString)) {
						responseVo.setStatus(false);
						responseVo.setMessage(resString);
					}
				}
			} else {
				responseVo.setStatus(false);
				responseVo.setMessage("修改密码失败,SESSION中未能找到用户");
			}
		}
	} catch (Exception e) {
		logger.error("修改密码异常", e);
		responseVo.setStatus(false);
		responseVo.setMessage(e.getMessage());
	}
	return responseVo;
}
 
源代码7 项目: mxisd   文件: EmailSendGridNotificationHandler.java
@Override
public void sendForInvite(IMatrixIdInvite invite) {
    EmailTemplate template = cfg.getTemplates().getGeneric().get("matrixId");
    if (StringUtils.isAllBlank(template.getBody().getText(), template.getBody().getHtml())) {
        throw new FeatureNotAvailable("No template has been configured for Matrix ID invite notifications");
    }

    Email email = getEmail();
    email.setSubject(populateForInvite(invite, template.getSubject()));
    email.setText(populateForInvite(invite, getFromFile(template.getBody().getText())));
    email.setHtml(populateForInvite(invite, getFromFile(template.getBody().getHtml())));

    send(invite.getAddress(), email);
}
 
源代码8 项目: mxisd   文件: EmailSendGridNotificationHandler.java
@Override
public void sendForReply(IThreePidInviteReply invite) {
    EmailTemplate template = cfg.getTemplates().getInvite();
    if (StringUtils.isAllBlank(template.getBody().getText(), template.getBody().getHtml())) {
        throw new FeatureNotAvailable("No template has been configured for 3PID invite notifications");
    }

    Email email = getEmail();
    email.setSubject(populateForReply(invite, template.getSubject()));
    email.setText(populateForReply(invite, getFromFile(template.getBody().getText())));
    email.setHtml(populateForReply(invite, getFromFile(template.getBody().getHtml())));

    send(invite.getInvite().getAddress(), email);
}
 
源代码9 项目: mxisd   文件: EmailSendGridNotificationHandler.java
@Override
public void sendForValidation(IThreePidSession session) {
    EmailTemplate template = cfg.getTemplates().getSession().getValidation();
    if (StringUtils.isAllBlank(template.getBody().getText(), template.getBody().getHtml())) {
        throw new FeatureNotAvailable("No template has been configured for validation notifications");
    }

    Email email = getEmail();
    email.setSubject(populateForValidation(session, template.getSubject()));
    email.setText(populateForValidation(session, getFromFile(template.getBody().getText())));
    email.setHtml(populateForValidation(session, getFromFile(template.getBody().getHtml())));

    send(session.getThreePid().getAddress(), email);
}
 
源代码10 项目: mxisd   文件: EmailSendGridNotificationHandler.java
@Override
public void sendForFraudulentUnbind(ThreePid tpid) {
    EmailTemplate template = cfg.getTemplates().getSession().getUnbind().getFraudulent();
    if (StringUtils.isAllBlank(template.getBody().getText(), template.getBody().getHtml())) {
        throw new FeatureNotAvailable("No template has been configured for fraudulent unbind notifications");
    }

    Email email = getEmail();
    email.setSubject(populateForCommon(tpid, template.getSubject()));
    email.setText(populateForCommon(tpid, getFromFile(template.getBody().getText())));
    email.setHtml(populateForCommon(tpid, getFromFile(template.getBody().getHtml())));

    send(tpid.getAddress(), email);
}
 
源代码11 项目: syncope   文件: GroupWizardBuilder.java
@Override
protected Serializable onApplyInternal(final AnyWrapper<GroupTO> modelObject) {
    GroupTO updated = modelObject instanceof GroupWrapper
            ? GroupWrapper.class.cast(modelObject).fillDynamicConditions()
            : modelObject.getInnerObject();

    ProvisioningResult<GroupTO> result;
    if (updated.getKey() == null) {
        GroupCR req = new GroupCR();
        EntityTOUtils.toAnyCR(updated, req);
        result = GroupRestClient.create(req);
    } else {
        GroupTO original = getOriginalItem().getInnerObject();
        fixPlainAndVirAttrs(updated, original);

        // SYNCOPE-1170
        boolean othersNotEqualsOrBlanks =
                !updated.getADynMembershipConds().equals(original.getADynMembershipConds())
                || (StringUtils.isNotBlank(original.getUDynMembershipCond())
                && StringUtils.isBlank(updated.getUDynMembershipCond()))
                || (StringUtils.isBlank(original.getUDynMembershipCond())
                && StringUtils.isNotBlank(updated.getUDynMembershipCond()))
                || StringUtils.isAllBlank(original.getUDynMembershipCond(), updated.getUDynMembershipCond())
                || !updated.getUDynMembershipCond().equals(original.getUDynMembershipCond())
                || !CollectionUtils.diff(updated.getTypeExtensions(), original.getTypeExtensions()).isEmpty();

        GroupUR groupUR = AnyOperations.diff(updated, original, false);

        // update just if it is changed
        if (groupUR.isEmpty() && !othersNotEqualsOrBlanks) {
            result = new ProvisioningResult<>();
            result.setEntity(updated);
        } else {
            result = groupRestClient.update(original.getETagValue(), groupUR);
        }
    }

    return result;
}
 
源代码12 项目: sakai   文件: ImportController.java
@PostMapping(value = "/importGroups", consumes = "multipart/form-data")
public String showImportGroups(@RequestParam(required=false) String groupUploadedText, Model model, HttpServletRequest req) {
    log.debug("showImportGroups called with value {}", groupUploadedText);

    // Variable definition
    Locale userLocale = sakaiService.getCurrentUserLocale();
    Map<String, List<String>> importedGroupMap = new HashMap<String, List<String>>();
    String uploadedText = StringUtils.EMPTY;
    String groupFileUploadedText = StringUtils.EMPTY;

    //Check the uploaded file and contents.
    FileItem uploadedFileItem = (FileItem) req.getAttribute("groupUploadFile");
    if (uploadedFileItem.getSize() > 0) {
        try (Scanner scanner = new Scanner(uploadedFileItem.getInputStream(), StandardCharsets.UTF_8.name())) {
            groupFileUploadedText = scanner.useDelimiter("\\A").next();
        } catch (Exception e) {
            log.error("The file {} provided is not valid.", uploadedFileItem.getName());
        }
    }

    // Check if both options are blank and return an error message
    if (StringUtils.isAllBlank(groupUploadedText, groupFileUploadedText)) {
        return returnImportError(model, "import.error.inputrequired", userLocale);
    }        

    // Process the submitted texts, combine the uploaded and the file into one String
    uploadedText = String.format("%s\r\n%s", groupUploadedText, groupFileUploadedText);

    String[] lineArray = uploadedText.split(BULK_LINE_DELIMITER);
    for (String line : lineArray) {

        if (StringUtils.isBlank(line)) {
            continue;
        }

        String[] lineContentArray = line.split(BULK_FIELD_DELIMITER);

        //Each line must contain a groupTitle and a userEid
        if (lineContentArray.length == 2) {
            String groupTitle = StringUtils.trimToNull(lineContentArray[0]);
            String userEid = StringUtils.trimToNull(lineContentArray[1]);

            if (StringUtils.isAnyBlank(groupTitle, userEid)) {
                // One of the items of the line is blank, redirect to the import form again displaying an error. 
                return returnImportError(model, "import.error.wrongformat", userLocale);
            }

            if (groupTitle.length() > 99) {
                // One of the items of the line has more than 99 characters, redirect to the import form again displaying an error. 
                return returnImportError(model, "import.error.titlelength", userLocale);
            }

            if (importedGroupMap.get(groupTitle) != null) {
                // If the map contains an entry for that group, add the user to the list
                importedGroupMap.get(groupTitle).add(userEid);
            } else {
                // If the map does not contain an entry for that group, create a list and add the member to the list
                List<String> newUserlist = new ArrayList<String>();
                newUserlist.add(userEid);
                importedGroupMap.put(groupTitle, newUserlist);
            }
        } else {
            // One line does not contain two items, redirect to the import form again displaying an error.
            return returnImportError(model, "import.error.wrongformat", userLocale);
        }
    }

    //Redirect to the confirmation page once the map are correct
    return showImportConfirmation(model, importedGroupMap);
}
 
源代码13 项目: sakai   文件: ImportController.java
@PostMapping(value = "/importGroups", consumes = "multipart/form-data")
public String showImportGroups(@RequestParam(required=false) String groupUploadedText, Model model, HttpServletRequest req) {
    log.debug("showImportGroups called with value {}", groupUploadedText);

    // Variable definition
    Locale userLocale = sakaiService.getCurrentUserLocale();
    Map<String, List<String>> importedGroupMap = new HashMap<String, List<String>>();
    String uploadedText = StringUtils.EMPTY;
    String groupFileUploadedText = StringUtils.EMPTY;

    //Check the uploaded file and contents.
    FileItem uploadedFileItem = (FileItem) req.getAttribute("groupUploadFile");
    if (uploadedFileItem.getSize() > 0) {
        try (Scanner scanner = new Scanner(uploadedFileItem.getInputStream(), StandardCharsets.UTF_8.name())) {
            groupFileUploadedText = scanner.useDelimiter("\\A").next();
        } catch (Exception e) {
            log.error("The file {} provided is not valid.", uploadedFileItem.getName());
        }
    }

    // Check if both options are blank and return an error message
    if (StringUtils.isAllBlank(groupUploadedText, groupFileUploadedText)) {
        return returnImportError(model, "import.error.inputrequired", userLocale);
    }        

    // Process the submitted texts, combine the uploaded and the file into one String
    uploadedText = String.format("%s\r\n%s", groupUploadedText, groupFileUploadedText);

    String[] lineArray = uploadedText.split(BULK_LINE_DELIMITER);
    for (String line : lineArray) {

        if (StringUtils.isBlank(line)) {
            continue;
        }

        String[] lineContentArray = line.split(BULK_FIELD_DELIMITER);

        //Each line must contain a groupTitle and a userEid
        if (lineContentArray.length == 2) {
            String groupTitle = StringUtils.trimToNull(lineContentArray[0]);
            String userEid = StringUtils.trimToNull(lineContentArray[1]);

            if (StringUtils.isAnyBlank(groupTitle, userEid)) {
                // One of the items of the line is blank, redirect to the import form again displaying an error. 
                return returnImportError(model, "import.error.wrongformat", userLocale);
            }

            if (groupTitle.length() > 99) {
                // One of the items of the line has more than 99 characters, redirect to the import form again displaying an error. 
                return returnImportError(model, "import.error.titlelength", userLocale);
            }

            if (importedGroupMap.get(groupTitle) != null) {
                // If the map contains an entry for that group, add the user to the list
                importedGroupMap.get(groupTitle).add(userEid);
            } else {
                // If the map does not contain an entry for that group, create a list and add the member to the list
                List<String> newUserlist = new ArrayList<String>();
                newUserlist.add(userEid);
                importedGroupMap.put(groupTitle, newUserlist);
            }
        } else {
            // One line does not contain two items, redirect to the import form again displaying an error.
            return returnImportError(model, "import.error.wrongformat", userLocale);
        }
    }

    //Redirect to the confirmation page once the map are correct
    return showImportConfirmation(model, importedGroupMap);
}
 
 同类方法