Java Code Examples for org.apache.commons.lang3.StringUtils.isBlank()

The following are Jave code examples for showing how to use isBlank() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: My-Blog   File: IndexController.java   View Source Code Vote up 6 votes
/**
 * 自定义页面,如关于的页面
 */
@GetMapping(value = "/{pagename}")
public String page(@PathVariable String pagename, HttpServletRequest request) {
    ContentVo contents = contentService.getContents(pagename);
    if (null == contents) {
        return this.render_404();
    }
    if (contents.getAllowComment()) {
        String cp = request.getParameter("cp");
        if (StringUtils.isBlank(cp)) {
            cp = "1";
        }
        PageInfo<CommentBo> commentsPaginator = commentService.getComments(contents.getCid(), Integer.parseInt(cp), 6);
        request.setAttribute("comments", commentsPaginator);
    }
    request.setAttribute("article", contents);
    updateArticleHit(contents.getCid(), contents.getHits());
    return this.render("page");
}
 
Example 2
Project: xq_seckill_microservice   File: CrawlerServiceImpl.java   View Source Code Vote up 6 votes
/**
 * 保存房源图片
 *
 * @param dto
 */
private void saveImages(EstateItemDTO dto) {
    List<EstateImageModel> imageList = dto.getEstateImageList();
    if (CollectionUtils.isNotEmpty(imageList)) {
        for (EstateImageModel image : imageList) {
            // 普通图片
            if (image.getPictureId() != null) {
                estateFeignClient.saveImage(image.getHouseCode(), ProtoStuffUtil.serialize(image));
                // 户型图
            } else {
                image.setPictureId(System.currentTimeMillis());
                image.setHouseCode(dto.getHouseCode());
                image.setPictureType(99);
                if (StringUtils.isBlank(image.getPictureSourceUrl())) {
                    image.setPictureSourceUrl(image.getUrl());
                }
                estateFeignClient.saveImage(image.getHouseCode(), ProtoStuffUtil.serialize(image));
            }
        }
    }
}
 
Example 3
Project: X-mall   File: CategoryServiceImpl.java   View Source Code Vote up 6 votes
@Override
public ServerResponse addCategory(String categoryName, Integer parentId) {
    if (parentId == null || StringUtils.isBlank(categoryName)) {
        return ServerResponse.createByErrorMessage("添加品类参数错误");
    }

    Category category = new Category();
    category.setName(categoryName);
    category.setParentId(parentId);
    category.setStatus(true);//这个分类是可用的

    int rowCount = categoryMapper.insert(category);
    if (rowCount > 0) {
        return ServerResponse.createBySuccess("添加品类成功");
    }
    return ServerResponse.createByErrorMessage("添加品类失败");
}
 
Example 4
Project: springboot-shiro-cas-mybatis   File: BaseSpnegoKnownClientSystemsFilterAction.java   View Source Code Vote up 6 votes
/**
 * Pulls the remote IP from the current HttpServletRequest, or grabs the value
 * for the specified alternative attribute (say, for proxied requests).  Falls
 * back to providing the "normal" remote address if no value can be retrieved
 * from the specified alternative header value.
 * @param context the context
 * @return the remote ip
 */
private String getRemoteIp(@NotNull final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    String userAddress = request.getRemoteAddr();
    logger.debug("Remote Address = {}", userAddress);

    if (StringUtils.isNotBlank(this.alternativeRemoteHostAttribute)) {

        userAddress = request.getHeader(this.alternativeRemoteHostAttribute);
        logger.debug("Header Attribute [{}] = [{}]", this.alternativeRemoteHostAttribute, userAddress);

        if (StringUtils.isBlank(userAddress)) {
            userAddress = request.getRemoteAddr();
            logger.warn("No value could be retrieved from the header [{}]. Falling back to [{}].",
                    this.alternativeRemoteHostAttribute, userAddress);
        }
    }
    return userAddress;
}
 
Example 5
Project: hippo-groovy-updater   File: YamlGenerator.java   View Source Code Vote up 6 votes
/**
 * Parse file to updater node
 *
 * @param scriptClass class to use for source
 * @return Node object representing the groovy updater to marshall to xml
 */
public static Map<String, Map<String, Object>> getUpdateYamlScript(final ScriptClass scriptClass) {
    final Updater updater = scriptClass.getUpdater();

    Map<String, Object> properties = new LinkedHashMap<>();
    addNotEmptyProperty(JCR_PRIMARY_TYPE, HIPPOSYS_UPDATERINFO, properties);

    addNotEmptyProperty(HIPPOSYS_BATCHSIZE, updater.batchSize(), properties);
    addNotEmptyProperty(HIPPOSYS_DESCRIPTION, updater.description(), properties);
    addNotEmptyProperty(HIPPOSYS_DRYRUN, updater.dryRun(), properties);
    addNotEmptyProperty(HIPPOSYS_PARAMETERS, updater.parameters(), properties);
    if (StringUtils.isBlank(updater.xpath())) {
        addNotEmptyProperty(HIPPOSYS_PATH, updater.path(), properties);
    }
    addNotEmptyProperty(HIPPOSYS_QUERY, updater.xpath(), properties);
    addNotEmptyProperty(HIPPOSYS_SCRIPT, removeEmptyIndents(scriptClass.getContent()), properties);
    addNotEmptyProperty(HIPPOSYS_THROTTLE, updater.throttle(), properties);
    return Collections.singletonMap(getBootstrapPath(scriptClass), properties);
}
 
Example 6
Project: shepher   File: SnapshotBiz.java   View Source Code Vote up 6 votes
public int update(long id, ReviewStatus reviewStatus, String reviewer, long zkMtime) throws ShepherException {
    if (StringUtils.isBlank(reviewer) || reviewStatus == null) {
        throw ShepherException.createIllegalParameterException();
    }
    try {
        return snapshotMapper.update(id, reviewStatus.getValue(), reviewer, new Date(zkMtime));
    } catch (Exception e) {
        throw ShepherException.createDBUpdateErrorException();
    }
}
 
Example 7
Project: solo-spring   File: PageMgmtService.java   View Source Code Vote up 6 votes
/**
 * Processes comments for page update.
 *
 * @param page
 *            the specified page to update
 * @throws Exception
 *             exception
 */
public void processCommentsForPageUpdate(final JSONObject page) throws Exception {
	final String pageId = page.getString(Keys.OBJECT_ID);

	final List<JSONObject> comments = commentDao.getComments(pageId, 1, Integer.MAX_VALUE);

	for (final JSONObject comment : comments) {
		final String commentId = comment.getString(Keys.OBJECT_ID);
		final String sharpURL = Comments.getCommentSharpURLForPage(page, commentId);

		comment.put(Comment.COMMENT_SHARP_URL, sharpURL);

		if (StringUtils.isBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID))) {
			comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
		}
		if (StringUtils.isBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_NAME))) {
			comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
		}

		commentDao.update(commentId, comment);
	}
}
 
Example 8
Project: bluegreen-manager   File: ElbClient.java   View Source Code Vote up 5 votes
private void assertNonBlankArgs(String elbName, String ec2InstanceId)
{
  if (StringUtils.isBlank(elbName))
  {
    throw new IllegalArgumentException("Blank elbName");
  }
  if (StringUtils.isBlank(ec2InstanceId))
  {
    throw new IllegalArgumentException("Blank ec2InstanceId");
  }
}
 
Example 9
Project: redirector   File: RedirectorEngine.java   View Source Code Vote up 5 votes
@Override
public InstanceInfo getHostByServer(Server server) {
    InstanceInfo instanceInfo;
    // TODO: check if redundant
    if (server == null) {
        loggingHelper.warn("No server found");
        return null;
    } else if (StringUtils.isBlank(server.getPath())) { // TODO: should we check that url is without templates instead?
        instanceInfo = getAdvancedServiceInstance(server);
    } else {
        boolean applyFilter = true; // all traffic should go to whitelisted stacks
        instanceInfo = getSimpleHostByServer(server, applyFilter);

        if (isServerInstanceInvalid(instanceInfo)) {
            // fallback from distribution
            if (server.getReturnStatementType() == ReturnStatementType.DISTRIBUTION_RULE
                    || server.getReturnStatementType() == ReturnStatementType.PATH_RULE) {
                String logMessage = "falling back to default server";
                sessionLog.write(sessionId.get(), logMessage);
                log.info(logMessage);
                instanceInfo = getDefaultHost();
            }
        }
    }
    if (instanceInfo == null) {
        // TODO: builder
        instanceInfo = new InstanceInfo(server, null);
    }

    return instanceInfo;
}
 
Example 10
Project: JAVA-   File: WxPayment.java   View Source Code Vote up 5 votes
/**
 * 组装签名的字段
 * 
 * @param params
 *            参数
 * @param urlEncoder
 *            是否urlEncoder
 * @return String
 */
public static String packageSign(Map<String, String> params, boolean urlEncoder) {
	// 先将参数以其参数名的字典序升序进行排序
	TreeMap<String, String> sortedParams = new TreeMap<String, String>(params);
	// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
	StringBuilder sb = new StringBuilder();
	boolean first = true;
	for (Entry<String, String> param : sortedParams.entrySet()) {
		String value = param.getValue();
		if (StringUtils.isBlank(value)) {
			continue;
		}
		if (first) {
			first = false;
		} else {
			sb.append("&");
		}
		sb.append(param.getKey()).append("=");
		if (urlEncoder) {
			try {
				value = urlEncode(value);
			} catch (UnsupportedEncodingException e) {
			}
		}
		sb.append(value);
	}
	return sb.toString();
}
 
Example 11
Project: wavemaker-app-build-tools   File: BasePackage.java   View Source Code Vote up 5 votes
private boolean checkIfEmptyPathExists(List<File> files){
    boolean emptyPathExists = false;

    if (files.size() > 0){
        for (int i=0; i<files.size(); i++){
            //Check if current folder of file is same as source folder
            if(StringUtils.isBlank(files.get(i).getParent().toStringRelativeTo(sourceFolder))){
                emptyPathExists = true;
                break;
            }
        }
    }

    return emptyPathExists;
}
 
Example 12
Project: spring-boot-frameset   File: ValidatorUtil.java   View Source Code Vote up 5 votes
/**
 * 功能:数字判断
 * @param str
 * @return
 */
public static boolean isNumeric(String str) {
	if (StringUtils.isBlank(str)) {
		return false;
	}
	
	if (str.matches("\\d*")) {
		return true;
	} else {
		return false;
	}
}
 
Example 13
Project: fastdfs-quickstart   File: SimpleJsonFileUploadProcessor.java   View Source Code Vote up 5 votes
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public FResult<JSONObject> process(UploadRequest request) throws Exception {
  Long commonFileId = null;
  try {
    File temporaryFile = new File(request.getTemporaryFilePath());
    if (temporaryFile == null || !temporaryFile.isFile() || !temporaryFile.exists()) {
      return FResult.newFailure(HttpResponseCode.SERVER_IO_READ, "上传失败");
    }
    String currentFileMd5 = request.getTemporaryFileMd5();
    String fileId = uploadFileReturnFileId(request.getTemporaryFilePath(), request.getSuffix());
    if (StringUtils.isBlank(fileId)) {
      return FResult.newFailure(HttpResponseCode.SERVER_IO_WRITE, "上传文件到FastDFS失败,请检查FastDFS日志");
    }
    long nowTimestamp = System.currentTimeMillis();
    // 要保存的对象
    UploadFile commonFile = new UploadFile();
    commonFile.setFilemd5(currentFileMd5);
    // 保存主文件后,返回住表ID
    log.debug("你可以控制是否要持久化这个文件");
    commonFileId = commonFileService.addUploadFile(nowTimestamp, commonFile, temporaryFile, request, fileId);
    if (commonFileId == null || commonFileId == 0) {
      log.error("insert common_file failed,record:" + JSON.toJSONString(commonFile));
      FileUtils.forceDelete(temporaryFile);
      return FResult.newFailure(HttpResponseCode.SERVER_DB_ERROR, "保存上传记录失败");
    }
    return buildResult(request.getOriginalFilename(), request.getTemporaryFileSize(), request.getTemporaryFileMd5(), commonFile.getUrl(),
        commonFile.getId());
  } catch (Exception uploadException) {
    log.error("普通文件上传过程中发生错误", uploadException);
    return FResult.newFailure(HttpResponseCode.SERVER_ERROR, "文件上传过程中发生错误");
  }
}
 
Example 14
Project: redisfx   File: ListTabController.java   View Source Code Vote up 5 votes
private void appendItem() {
    String value = getStringByDialog("");
    if (StringUtils.isBlank(value)) {
        return;
    }

    JedisManager.withJedis(jedis -> jedis.lpush(currentKey, value));
    refreshList();
}
 
Example 15
Project: nifi-registry   File: JerseyBucketClient.java   View Source Code Vote up 5 votes
@Override
public Bucket get(final String bucketId) throws NiFiRegistryException, IOException {
    if (StringUtils.isBlank(bucketId)) {
        throw new IllegalArgumentException("Bucket ID cannot be blank");
    }

    return executeAction("Error retrieving bucket", () -> {
        final WebTarget target = bucketsTarget
                .path("/{bucketId}")
                .resolveTemplate("bucketId", bucketId);

        return getRequestBuilder(target).get(Bucket.class);
    });

}
 
Example 16
Project: nifi-registry   File: JettyServer.java   View Source Code Vote up 4 votes
private SslContextFactory createSslContextFactory() {
    final SslContextFactory contextFactory = new SslContextFactory();

    // if needClientAuth is false then set want to true so we can optionally use certs
    if (properties.getNeedClientAuth()) {
        logger.info("Setting Jetty's SSLContextFactory needClientAuth to true");
        contextFactory.setNeedClientAuth(true);
    } else {
        logger.info("Setting Jetty's SSLContextFactory wantClientAuth to true");
        contextFactory.setWantClientAuth(true);
    }

    /* below code sets JSSE system properties when values are provided */
    // keystore properties
    if (StringUtils.isNotBlank(properties.getKeyStorePath())) {
        contextFactory.setKeyStorePath(properties.getKeyStorePath());
    }
    if (StringUtils.isNotBlank(properties.getKeyStoreType())) {
        contextFactory.setKeyStoreType(properties.getKeyStoreType());
    }
    final String keystorePassword = properties.getKeyStorePassword();
    final String keyPassword = properties.getKeyPassword();
    if (StringUtils.isNotBlank(keystorePassword)) {
        // if no key password was provided, then assume the keystore password is the same as the key password.
        final String defaultKeyPassword = (StringUtils.isBlank(keyPassword)) ? keystorePassword : keyPassword;
        contextFactory.setKeyManagerPassword(keystorePassword);
        contextFactory.setKeyStorePassword(defaultKeyPassword);
    } else if (StringUtils.isNotBlank(keyPassword)) {
        // since no keystore password was provided, there will be no keystore integrity check
        contextFactory.setKeyStorePassword(keyPassword);
    }

    // truststore properties
    if (StringUtils.isNotBlank(properties.getTrustStorePath())) {
        contextFactory.setTrustStorePath(properties.getTrustStorePath());
    }
    if (StringUtils.isNotBlank(properties.getTrustStoreType())) {
        contextFactory.setTrustStoreType(properties.getTrustStoreType());
    }
    if (StringUtils.isNotBlank(properties.getTrustStorePassword())) {
        contextFactory.setTrustStorePassword(properties.getTrustStorePassword());
    }

    return contextFactory;
}
 
Example 17
Project: iBase4J-Common   File: AliPayConfig.java   View Source Code Vote up 4 votes
public String getAlipayPublicKey() {
    if (StringUtils.isBlank(alipayPublicKey)) throw new IllegalStateException("alipayPublicKey 未被赋值");
    return alipayPublicKey;
}
 
Example 18
Project: cas-server-4.2.1   File: OAuth20CallbackAuthorizeController.java   View Source Code Vote up 4 votes
@Override
protected ModelAndView internalHandleRequest(final String method, final HttpServletRequest request,
                                             final HttpServletResponse response) throws Exception {
    // get CAS ticket
    final String ticket = request.getParameter(OAuthConstants.TICKET);
    logger.debug("{} : {}", OAuthConstants.TICKET, ticket);

    // retrieve callback url from session
    final HttpSession session = request.getSession();
    String callbackUrl = (String) session.getAttribute(OAuthConstants.OAUTH20_CALLBACKURL);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);
    session.removeAttribute(OAuthConstants.OAUTH20_CALLBACKURL);

    if (StringUtils.isBlank(callbackUrl)) {
        logger.error("{} is missing from the session and can not be retrieved.", OAuthConstants.OAUTH20_CALLBACKURL);
        return new ModelAndView(OAuthConstants.ERROR_VIEW);
    }
    // and state
    final String state = (String) session.getAttribute(OAuthConstants.OAUTH20_STATE);
    logger.debug("{} : {}", OAuthConstants.OAUTH20_STATE, state);
    session.removeAttribute(OAuthConstants.OAUTH20_STATE);

    // return callback url with code & state
    callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.CODE, ticket);
    if (state != null) {
        callbackUrl = OAuthUtils.addParameter(callbackUrl, OAuthConstants.STATE, state);
    }
    logger.debug("{} : {}", OAuthConstants.OAUTH20_CALLBACKURL, callbackUrl);

    final Map<String, Object> model = new HashMap<>();
    model.put("callbackUrl", callbackUrl);

    final Boolean bypassApprovalPrompt = (Boolean) session.getAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);
    logger.debug("bypassApprovalPrompt : {}", bypassApprovalPrompt);
    session.removeAttribute(OAuthConstants.BYPASS_APPROVAL_PROMPT);

    // Clients that auto-approve do not need authorization.
    if (bypassApprovalPrompt != null && bypassApprovalPrompt) {
        return OAuthUtils.redirectTo(callbackUrl);
    }

    // retrieve service name from session
    final String serviceName = (String) session.getAttribute(OAuthConstants.OAUTH20_SERVICE_NAME);
    logger.debug("serviceName : {}", serviceName);
    model.put("serviceName", serviceName);

    return new ModelAndView(OAuthConstants.CONFIRM_VIEW, model);

}
 
Example 19
Project: cas-5.1.0   File: SamlIdPUtils.java   View Source Code Vote up 4 votes
/**
 * Gets assertion consumer service for.
 *
 * @param authnRequest    the authn request
 * @param servicesManager the services manager
 * @param resolver        the resolver
 * @return the assertion consumer service for
 */
public static AssertionConsumerService getAssertionConsumerServiceFor(final AuthnRequest authnRequest,
                                                                      final ServicesManager servicesManager,
                                                                      final SamlRegisteredServiceCachingMetadataResolver resolver) {
    try {
        final AssertionConsumerService acs = new AssertionConsumerServiceBuilder().buildObject();
        if (authnRequest.getAssertionConsumerServiceIndex() != null) {
            final String issuer = getIssuerFromSamlRequest(authnRequest);
            final MetadataResolver samlResolver = getMetadataResolverForAllSamlServices(servicesManager, issuer, resolver);
            final CriteriaSet criteriaSet = new CriteriaSet();
            criteriaSet.add(new EntityIdCriterion(issuer));
            criteriaSet.add(new EntityRoleCriterion(SPSSODescriptor.DEFAULT_ELEMENT_NAME));
            criteriaSet.add(new BindingCriterion(Arrays.asList(SAMLConstants.SAML2_POST_BINDING_URI)));

            final Iterable<EntityDescriptor> it = samlResolver.resolve(criteriaSet);
            it.forEach(entityDescriptor -> {
                final SPSSODescriptor spssoDescriptor = entityDescriptor.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
                final List<AssertionConsumerService> acsEndpoints = spssoDescriptor.getAssertionConsumerServices();
                if (acsEndpoints.isEmpty()) {
                    throw new RuntimeException("Metadata resolved for entity id " + issuer + " has no defined ACS endpoints");
                }
                final int acsIndex = authnRequest.getAssertionConsumerServiceIndex();
                if (acsIndex + 1 > acsEndpoints.size()) {
                    throw new RuntimeException("AssertionConsumerService index specified in the request " + acsIndex + " is invalid "
                            + "since the total endpoints available to " + issuer + " is " + acsEndpoints.size());
                }
                final AssertionConsumerService foundAcs = acsEndpoints.get(acsIndex);
                acs.setBinding(foundAcs.getBinding());
                acs.setLocation(foundAcs.getLocation());
                acs.setResponseLocation(foundAcs.getResponseLocation());
                acs.setIndex(acsIndex);
            });
        } else {
            acs.setBinding(authnRequest.getProtocolBinding());
            acs.setLocation(authnRequest.getAssertionConsumerServiceURL());
            acs.setResponseLocation(authnRequest.getAssertionConsumerServiceURL());
            acs.setIndex(0);
            acs.setIsDefault(Boolean.TRUE);
        }

        LOGGER.debug("Resolved AssertionConsumerService from the request is [{}]", acs);
        if (StringUtils.isBlank(acs.getBinding())) {
            throw new SamlException("AssertionConsumerService has no protocol binding defined");
        }
        if (StringUtils.isBlank(acs.getLocation()) && StringUtils.isBlank(acs.getResponseLocation())) {
            throw new SamlException("AssertionConsumerService has no location or response location defined");
        }
        return acs;
    } catch (final Exception e) {
        throw new RuntimeException(new SamlException(e.getMessage(), e));
    }
}
 
Example 20
Project: cas-5.1.0   File: OAuth20AuthorizeEndpointController.java   View Source Code Vote up 4 votes
/**
 * Redirect to callback redirect url model and view.
 *
 * @param manager           the manager
 * @param registeredService the registered service
 * @param context           the context
 * @param clientId          the client id
 * @return the model and view
 * @throws Exception the exception
 */
protected ModelAndView redirectToCallbackRedirectUrl(final ProfileManager manager,
                                                     final OAuthRegisteredService registeredService,
                                                     final J2EContext context,
                                                     final String clientId) throws Exception {
    final Optional<UserProfile> profile = manager.get(true);
    if (profile == null || !profile.isPresent()) {
        LOGGER.error("Unexpected null profile from profile manager. Request is not fully authenticated.");
        return OAuth20Utils.produceUnauthorizedErrorView();
    }

    final Service service = this.authenticationBuilder.buildService(registeredService, context, false);
    LOGGER.debug("Created service [{}] based on registered service [{}]", service, registeredService);

    final Authentication authentication = this.authenticationBuilder.build(profile.get(), registeredService, context, service);
    LOGGER.debug("Created OAuth authentication [{}] for service [{}]", service, authentication);

    try {
        RegisteredServiceAccessStrategyUtils.ensurePrincipalAccessIsAllowedForService(service, registeredService, authentication);
    } catch (final UnauthorizedServiceException | PrincipalException e) {
        LOGGER.error(e.getMessage(), e);
        return OAuth20Utils.produceUnauthorizedErrorView();
    }

    final String redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI);
    LOGGER.debug("Authorize request verification successful for client [{}] with redirect uri [{}]", clientId, redirectUri);

    final String responseType = context.getRequestParameter(OAuth20Constants.RESPONSE_TYPE);

    final TicketGrantingTicket ticketGrantingTicket = CookieUtils.getTicketGrantingTicketFromRequest(
            ticketGrantingTicketCookieGenerator, this.ticketRegistry, context.getRequest());
    final String callbackUrl;
    if (OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.CODE)) {
        callbackUrl = buildCallbackUrlForAuthorizationCodeResponseType(authentication, service, redirectUri, ticketGrantingTicket);
    } else if (OAuth20Utils.isResponseType(responseType, OAuth20ResponseTypes.TOKEN)) {
        final AccessTokenRequestDataHolder holder = new AccessTokenRequestDataHolder(service, authentication, 
                registeredService, ticketGrantingTicket);
        callbackUrl = buildCallbackUrlForImplicitTokenResponseType(holder, redirectUri);
    } else {
        callbackUrl = buildCallbackUrlForTokenResponseType(context, authentication, service, redirectUri, responseType, clientId);
    }

    LOGGER.debug("Callback URL to redirect: [{}]", callbackUrl);
    if (StringUtils.isBlank(callbackUrl)) {
        return OAuth20Utils.produceUnauthorizedErrorView();
    }
    return OAuth20Utils.redirectTo(callbackUrl);
}