本文整理汇总了Java中org.pac4j.core.profile.CommonProfile.getId方法的典型用法代码示例。如果您正苦于以下问题:Java CommonProfile.getId方法的具体用法?Java CommonProfile.getId怎么用?Java CommonProfile.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pac4j.core.profile.CommonProfile
的用法示例。
在下文中一共展示了CommonProfile.getId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generate
import org.pac4j.core.profile.CommonProfile; //导入方法依赖的package包/类
@Override
public CommonProfile generate(final WebContext context, final CommonProfile profile) {
Assert.notNull(this.connectionFactory, "connectionFactory must not be null");
Assert.notNull(this.userSearchExecutor, "userSearchExecutor must not be null");
final String username = profile.getId();
final SearchResult userResult;
try {
LOGGER.debug("Attempting to get details for user [{}].", username);
final Response<SearchResult> response = this.userSearchExecutor.search(
this.connectionFactory,
Beans.newLdaptiveSearchFilter(this.userSearchExecutor.getSearchFilter().getFilter(),
Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, Collections.singletonList(username)));
LOGGER.debug("LDAP user search response: [{}]", response);
userResult = response.getResult();
if (userResult.size() == 0) {
throw new RuntimeException(new AccountNotFoundException(username + " not found."));
}
if (userResult.size() > 1 && !this.allowMultipleResults) {
throw new IllegalStateException(
"Found multiple results for user which is not allowed (allowMultipleResults=false).");
}
final LdapEntry userEntry = userResult.getEntry();
return generateAuthorizationForLdapEntry(profile, userEntry);
} catch (final LdapException e) {
throw new RuntimeException("LDAP error fetching details for user.", e);
}
}