本文整理汇总了Java中org.pac4j.core.util.CommonHelper.isNotEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java CommonHelper.isNotEmpty方法的具体用法?Java CommonHelper.isNotEmpty怎么用?Java CommonHelper.isNotEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.util.CommonHelper
的用法示例。
在下文中一共展示了CommonHelper.isNotEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: internalInit
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
protected void internalInit(final WebContext context) {
CommonHelper.assertNotNull("configuration", configuration);
configuration.init(context);
// check authentication methods
final List<ClientAuthenticationMethod> metadataMethods = configuration.getProviderMetadata().getTokenEndpointAuthMethods();
final ClientAuthenticationMethod chosenMethod;
final ClientAuthenticationMethod configurationMethod = configuration.getClientAuthenticationMethod();
if (CommonHelper.isNotEmpty(metadataMethods)) {
if (metadataMethods.contains(configurationMethod)) {
chosenMethod = configurationMethod;
} else {
chosenMethod = metadataMethods.get(0);
logger.warn("Preferred token endpoint Authentication method: {} not available. Defaulting to: {}",
configurationMethod, chosenMethod);
}
} else {
chosenMethod = ClientAuthenticationMethod.getDefault();
logger.warn("Provider metadata does not provide Token endpoint authentication methods. Defaulting to: {}",
chosenMethod);
}
final ClientID _clientID = new ClientID(configuration.getClientId());
final Secret _secret = new Secret(configuration.getSecret());
if (ClientAuthenticationMethod.CLIENT_SECRET_POST.equals(chosenMethod)) {
clientAuthentication = new ClientSecretPost(_clientID, _secret);
} else if (ClientAuthenticationMethod.CLIENT_SECRET_BASIC.equals(chosenMethod)) {
clientAuthentication = new ClientSecretBasic(_clientID, _secret);
} else {
throw new TechnicalException("Unsupported client authentication method: " + chosenMethod);
}
}
示例2: addContext
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
protected final void addContext(final SAML2MetadataResolver entityId, final BaseContext parentContext,
final QName elementName) {
final EntityDescriptor entityDescriptor;
final RoleDescriptor roleDescriptor;
try {
final CriteriaSet set = new CriteriaSet();
set.add(new EntityIdCriterion(entityId.getEntityId()));
entityDescriptor = this.metadata.resolveSingle(set);
if (entityDescriptor == null) {
throw new SAMLException("Cannot find entity " + entityId + " in metadata provider");
}
final List<RoleDescriptor> list = entityDescriptor.getRoleDescriptors(elementName,
SAMLConstants.SAML20P_NS);
roleDescriptor = CommonHelper.isNotEmpty(list) ? list.get(0) : null;
if (roleDescriptor == null) {
throw new SAMLException("Cannot find entity " + entityId + " or role "
+ elementName + " in metadata provider");
}
} catch (final ResolverException e) {
throw new SAMLException("An error occured while getting IDP descriptors", e);
}
final SAMLMetadataContext mdCtx = parentContext.getSubcontext(SAMLMetadataContext.class, true);
mdCtx.setEntityDescriptor(entityDescriptor);
mdCtx.setRoleDescriptor(roleDescriptor);
}
示例3: startAuthentication
import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
protected boolean startAuthentication(C context, List<Client> currentClients) {
return CommonHelper.isNotEmpty(currentClients) && currentClients.get(0) instanceof IndirectClient;
}