本文整理汇总了Java中org.pac4j.core.util.CommonHelper.isNotBlank方法的典型用法代码示例。如果您正苦于以下问题:Java CommonHelper.isNotBlank方法的具体用法?Java CommonHelper.isNotBlank怎么用?Java CommonHelper.isNotBlank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.util.CommonHelper
的用法示例。
在下文中一共展示了CommonHelper.isNotBlank方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryCreateCasClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateCasClient(final List<Client> clients) {
for (int i = 0; i <= MAX_NUM_CLIENTS; i++) {
final String loginUrl = getProperty(CAS_LOGIN_URL.concat(i == 0 ? "" : "." + i));
final String protocol = getProperty(CAS_PROTOCOL.concat(i == 0 ? "" : "." + i));
if (CommonHelper.isNotBlank(loginUrl)) {
CasConfiguration configuration = new CasConfiguration();
final CasClient casClient = new CasClient(configuration);
configuration.setLoginUrl(loginUrl);
if (CommonHelper.isNotBlank(protocol)) {
configuration.setProtocol(CasProtocol.valueOf(protocol));
}
if (i != 0) {
casClient.setName(casClient.getName().concat("." + i));
}
clients.add(casClient);
}
}
}
示例2: getRedirectAction
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
* <p>Get the redirectAction computed for this client. All the logic is encapsulated here. It should not be called be directly, the
* {@link #redirect(WebContext)} should be generally called instead.</p>
* <p>If an authentication has already been tried for this client and has failed (<code>null</code> credentials) or if the request is an AJAX one,
* an authorized response (401 HTTP status code) is returned instead of a redirection.</p>
*
* @param context context
* @return the redirection action
* @throws HttpAction requires an additional HTTP action
*/
public final RedirectAction getRedirectAction(final WebContext context) throws HttpAction {
init(context);
// it's an AJAX request -> unauthorized (instead of a redirection)
if (ajaxRequestResolver.isAjax(context)) {
logger.info("AJAX request detected -> returning 401");
cleanRequestedUrl(context);
throw HttpAction.unauthorized("AJAX request -> 401", context, null);
}
// authentication has already been tried -> unauthorized
final String attemptedAuth = (String) context.getSessionAttribute(getName() + ATTEMPTED_AUTHENTICATION_SUFFIX);
if (CommonHelper.isNotBlank(attemptedAuth)) {
cleanAttemptedAuthentication(context);
cleanRequestedUrl(context);
throw HttpAction.unauthorized("authentication already tried -> forbidden", context, null);
}
return retrieveRedirectAction(context);
}
示例3: tryCreateFacebookClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateFacebookClient(final List<Client> clients) {
final String id = getProperty(FACEBOOK_ID);
final String secret = getProperty(FACEBOOK_SECRET);
final String scope = getProperty(FACEBOOK_SCOPE);
final String fields = getProperty(FACEBOOK_FIELDS);
if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
final FacebookClient facebookClient = new FacebookClient(id, secret);
if (CommonHelper.isNotBlank(scope)) {
facebookClient.setScope(scope);
}
if (CommonHelper.isNotBlank(fields)) {
facebookClient.setFields(fields);
}
clients.add(facebookClient);
}
}
示例4: isAuthorized
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
public Boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
CommonHelper.assertNotBlank("allowOrigin", allowOrigin);
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, allowOrigin);
if (CommonHelper.isNotBlank(exposeHeaders)) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, exposeHeaders);
}
if (maxAge != -1) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_MAX_AGE_HEADER, "" + maxAge);
}
if (allowCredentials != null) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, allowCredentials.toString());
}
if (allowMethods != null) {
final String methods = allowMethods.stream().map(m -> m.toString()).collect(Collectors.joining(", "));
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_METHODS_HEADER, methods);
}
if (CommonHelper.isNotBlank(allowHeaders)) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_HEADERS_HEADER, allowHeaders);
}
return true;
}
示例5: tryCreateYahooClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateYahooClient(final List<Client> clients) {
final String id = getProperty(YAHOO_ID);
final String secret = getProperty(YAHOO_SECRET);
if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
final YahooClient client = new YahooClient(id, secret);
clients.add(client);
}
}
示例6: getStateParameter
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
protected String getStateParameter() {
final String stateData = this.configuration.getStateData();
final String stateParameter;
if (CommonHelper.isNotBlank(stateData)) {
stateParameter = stateData;
} else {
stateParameter = CommonHelper.randomString(10);
}
return stateParameter;
}
示例7: convert
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
public String convert(final Object attribute) {
if (attribute != null && attribute instanceof String) {
final String s = (String) attribute;
if (CommonHelper.isNotBlank(s) && CommonHelper.isNotBlank(this.regex)
&& CommonHelper.isNotBlank(this.replacement)) {
return s.replaceAll(this.regex, this.replacement);
}
}
return null;
}
示例8: internalInit
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
CommonHelper.assertNotBlank("headerName", this.headerName);
CommonHelper.assertNotNull("prefixHeader", this.prefixHeader);
setCredentialsExtractor(new BasicAuthExtractor(this.headerName, this.prefixHeader, getName()));
if (CommonHelper.isNotBlank(this.casServerPrefixUrl)) {
setAuthenticator(new CasRestAuthenticator(this.casServerPrefixUrl));
}
}
示例9: tryCreateGithubClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateGithubClient(final List<Client> clients) {
final String id = getProperty(GITHUB_ID);
final String secret = getProperty(GITHUB_SECRET);
if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
final GitHubClient client = new GitHubClient(id, secret);
clients.add(client);
}
}
示例10: setExcludePath
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
public void setExcludePath(String excludePath) {
this.excludePath = excludePath;
if (CommonHelper.isNotBlank(excludePath)) {
logger.warn("Excluding paths is an advanced feature: be careful when defining your regular expression to avoid any security issue!");
if (!excludePath.startsWith("^") || !excludePath.endsWith("$")) {
final String msg = "Your regular expression: '" + excludePath + "' must start with a ^ and ends with a $ to define a full path matching";
logger.error(msg);
throw new TechnicalException(msg);
}
pattern = Pattern.compile(excludePath);
}
}
示例11: internalInit
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
CommonHelper.assertNotNull("configuration", configuration);
configuration.init(context);
this.authParams = new HashMap<>();
// add scope
final String scope = configuration.getScope();
if(CommonHelper.isNotBlank(scope)){
this.authParams.put(OidcConfiguration.SCOPE, scope);
} else {
// default values
this.authParams.put(OidcConfiguration.SCOPE, "openid profile email");
}
// add response type
final String responseType = configuration.getResponseType();
if (CommonHelper.isNotBlank(responseType)) {
this.authParams.put(OidcConfiguration.RESPONSE_TYPE, responseType);
} else {
this.authParams.put(OidcConfiguration.RESPONSE_TYPE, "code");
}
// add response mode?
final String responseMode = configuration.getResponseMode();
if (CommonHelper.isNotBlank(responseMode)) {
this.authParams.put(OidcConfiguration.RESPONSE_MODE, responseMode);
}
this.authParams.put(OidcConfiguration.REDIRECT_URI, configuration.getCallbackUrl());
// add custom values
this.authParams.putAll(configuration.getCustomParams());
// client id
this.authParams.put(OidcConfiguration.CLIENT_ID, configuration.getClientId());
}
示例12: tryCreateTwitterClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateTwitterClient(final List<Client> clients) {
final String id = getProperty(TWITTER_ID);
final String secret = getProperty(TWITTER_SECRET);
if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
final TwitterClient twitterClient = new TwitterClient(id, secret);
clients.add(twitterClient);
}
}
示例13: isAuthorized
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
public boolean isAuthorized(WebContext context, List<CommonProfile> profiles) throws HttpAction {
CommonHelper.assertNotBlank("allowOrigin", allowOrigin);
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, allowOrigin);
if (CommonHelper.isNotBlank(exposeHeaders)) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_EXPOSE_HEADERS_HEADER, exposeHeaders);
}
if (maxAge != -1) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_MAX_AGE_HEADER, "" + maxAge);
}
if (allowCredentials != null) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_CREDENTIALS_HEADER, allowCredentials.toString());
}
if (allowMethods != null) {
final String methods = allowMethods.stream().map(m -> m.toString()).collect(Collectors.joining(", "));
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_METHODS_HEADER, methods);
}
if (CommonHelper.isNotBlank(allowHeaders)) {
context.setResponseHeader(HttpConstants.ACCESS_CONTROL_ALLOW_HEADERS_HEADER, allowHeaders);
}
return true;
}
示例14: getStateParameter
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
protected String getStateParameter(final WebContext context) {
final String stateParameter;
if (CommonHelper.isNotBlank(stateData)) {
stateParameter = stateData;
} else {
stateParameter = CommonHelper.randomString(10);
}
return stateParameter;
}
示例15: tryCreateWindowsLiveClient
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private void tryCreateWindowsLiveClient(final List<Client> clients) {
final String id = getProperty(WINDOWSLIVE_ID);
final String secret = getProperty(WINDOWSLIVE_SECRET);
if (CommonHelper.isNotBlank(id) && CommonHelper.isNotBlank(secret)) {
final WindowsLiveClient client = new WindowsLiveClient(id, secret);
clients.add(client);
}
}