本文整理汇总了Java中org.pac4j.core.profile.UserProfile类的典型用法代码示例。如果您正苦于以下问题:Java UserProfile类的具体用法?Java UserProfile怎么用?Java UserProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserProfile类属于org.pac4j.core.profile包,在下文中一共展示了UserProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createResult
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Build the handler result.
*
* @param credentials the provided credentials
* @param profile the retrieved user profile
* @return the built handler result
* @throws GeneralSecurityException On authentication failure.
* @throws PreventedException On the indeterminate case when authentication is prevented.
*/
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
if (profile != null) {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
credentials.setTypedIdUsed(typedIdUsed);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:34,代码来源:AbstractPac4jAuthenticationHandler.java
示例2: doAuthentication
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
final ClientCredential clientCredentials = (ClientCredential) credential;
logger.debug("clientCredentials {}", clientCredentials);
final Credentials credentials = clientCredentials.getCredentials();
final String clientName = credentials.getClientName();
logger.debug("clientName: {}", clientName);
// get client
final Client<Credentials, UserProfile> client = this.clients.findClient(clientName);
logger.debug("client: {}", client);
// web context
final HttpServletRequest request = WebUtils.getHttpServletRequest();
final HttpServletResponse response = WebUtils.getHttpServletResponse();
final WebContext webContext = new J2EContext(request, response);
// get user profile
final UserProfile userProfile = client.getUserProfile(credentials, webContext);
logger.debug("userProfile: {}", userProfile);
return createResult(clientCredentials, userProfile);
}
示例3: doAuthentication
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
CommonHelper.assertNotNull("profileCreator", this.profileCreator);
final C credentials = convertToPac4jCredentials((I) credential);
logger.debug("credentials: {}", credentials);
try {
final Authenticator authenticator = getAuthenticator(credential);
CommonHelper.assertNotNull("authenticator", authenticator);
authenticator.validate(credentials);
} catch (final CredentialsException e) {
logger.error("Failed to validate credentials", e);
throw new FailedLoginException("Failed to validate credentials: " + e.getMessage());
}
final UserProfile profile = profileCreator.create(credentials);
logger.debug("profile: {}", profile);
return createResult(new ClientCredential(credentials), profile);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:22,代码来源:AbstractWrapperAuthenticationHandler.java
示例4: getAuthenticatedUsername
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Return the username of the authenticated user (based on pac4j security).
*
* @return the authenticated username.
*/
public static String getAuthenticatedUsername() {
final HttpServletRequest request = getHttpServletRequest();
final HttpServletResponse response = getHttpServletResponse();
if (request != null && response != null) {
final J2EContext context = new J2EContext(request, response);
final ProfileManager manager = new ProfileManager(context);
final UserProfile profile = manager.get(true);
if (profile != null) {
final String id = profile.getId();
if (id != null) {
return id;
}
}
}
return UNKNOWN_USER;
}
示例5: createResult
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
示例6: generate
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Generate string.
*
* @param request the request
* @param response the response
* @param accessTokenId the access token id
* @param timeout the timeout
* @param responseType the response type
* @param registeredService the registered service
* @return the string
* @throws Exception the exception
*/
public String generate(final HttpServletRequest request,
final HttpServletResponse response,
final AccessToken accessTokenId,
final long timeout,
final OAuth20ResponseTypes responseType,
final OAuthRegisteredService registeredService) throws Exception {
final OidcRegisteredService oidcRegisteredService = (OidcRegisteredService) registeredService;
final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
final Optional<UserProfile> profile = manager.get(true);
LOGGER.debug("Attempting to produce claims for the id token [{}]", accessTokenId);
final JwtClaims claims = produceIdTokenClaims(request, accessTokenId, timeout,
oidcRegisteredService, profile.get(), context, responseType);
LOGGER.debug("Produce claims for the id token [{}] as [{}]", accessTokenId, claims);
return this.signingService.encode(oidcRegisteredService, claims);
}
示例7: extract
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
public AccessTokenRequestDataHolder extract() {
final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
final String grantType = request.getParameter(OAuth20Constants.GRANT_TYPE);
LOGGER.debug("OAuth grant type is [{}]", grantType);
final Optional<UserProfile> profile = manager.get(true);
final String clientId = profile.get().getId();
final OAuthRegisteredService registeredService = OAuth20Utils.getRegisteredOAuthService(this.servicesManager, clientId);
LOGGER.debug("Located OAuth registered service [{}]", registeredService);
// we generate a refresh token if requested by the service but not from a refresh token
final boolean generateRefreshToken = isAllowedToGenerateRefreshToken(registeredService);
final OAuthToken token = getOAuthTokenFromRequest();
if (token == null) {
throw new InvalidTicketException(getOAuthParameter());
}
return new AccessTokenRequestDataHolder(token, generateRefreshToken, registeredService);
}
示例8: createResult
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Build the handler result.
*
* @param credentials the provided credentials
* @param profile the retrieved user profile
* @return the built handler result
* @throws GeneralSecurityException On authentication failure.
* @throws PreventedException On the indeterminate case when authentication is prevented.
*/
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
if (profile != null) {
final String id;
if (isTypedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
credentials.setTypedIdUsed(isTypedIdUsed);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials);
}
示例9: getAuthenticatedUsername
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Return the username of the authenticated user (based on pac4j security).
*
* @return the authenticated username.
*/
public static String getAuthenticatedUsername() {
final HttpServletRequest request = getHttpServletRequestFromRequestAttributes();
final HttpServletResponse response = getHttpServletResponseFromRequestAttributes();
if (request != null && response != null) {
final ProfileManager manager = getPac4jProfileManager(request, response);
final Optional<UserProfile> profile = manager.get(true);
if (profile != null && profile.isPresent()) {
final String id = profile.get().getId();
if (id != null) {
return id;
}
}
}
return PrincipalResolver.UNKNOWN_USER;
}
示例10: generate
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* Generate string.
*
* @param request the request
* @param response the response
* @param accessTokenId the access token id
* @param timeout the timeout
* @param responseType the response type
* @param registeredService the registered service
* @return the string
* @throws Exception the exception
*/
public String generate(final HttpServletRequest request,
final HttpServletResponse response,
final AccessToken accessTokenId,
final long timeout,
final OAuth20ResponseTypes responseType,
final OAuthRegisteredService registeredService) throws Exception {
final OidcRegisteredService oidcRegisteredService = (OidcRegisteredService) registeredService;
final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
final ProfileManager manager = WebUtils.getPac4jProfileManager(request, response);
final Optional<UserProfile> profile = manager.get(true);
LOGGER.debug("Attempting to produce claims for the id token [{}]", accessTokenId);
final JwtClaims claims = produceIdTokenClaims(request, accessTokenId, timeout,
oidcRegisteredService, profile.get(), context, responseType);
LOGGER.debug("Produce claims for the id token [{}] as [{}]", accessTokenId, claims);
return this.signingService.encode(oidcRegisteredService, claims);
}
示例11: createResult
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
credentials.setTypedIdUsed(typedIdUsed);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
示例12: doAuthentication
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
final ClientCredential clientCredentials = (ClientCredential) credential;
logger.debug("clientCredentials : {}", clientCredentials);
final String clientName = clientCredentials.getCredentials().getClientName();
logger.debug("clientName : {}", clientName);
// get client
final Client<org.pac4j.core.credentials.Credentials, UserProfile> client = this.clients.findClient(clientName);
logger.debug("client : {}", client);
// get user profile
final UserProfile userProfile = client.getUserProfile(clientCredentials.getCredentials());
logger.debug("userProfile : {}", userProfile);
if (userProfile != null && StringUtils.isNotBlank(userProfile.getTypedId())) {
clientCredentials.setUserProfile(userProfile);
return new HandlerResult(
this,
new BasicCredentialMetaData(credential),
new SimplePrincipal(userProfile.getTypedId(), userProfile.getAttributes()));
}
throw new FailedLoginException("Provider did not produce profile for " + clientCredentials);
}
示例13: retrieveProfile
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
protected User retrieveProfile(Session session) {
Object profile = session.getAttribute(PRINCIPAL);
if (profile == null) {
return null;
}
Client client = getClient(session);
Class<UserProfile> type = Generics.getTypeParameter(client.getClass(), UserProfile.class);
if (type.isAssignableFrom(profile.getClass())) {
return new User((UserProfile) profile);
}
if (profile instanceof Map) {
String buffer = Serializer.DEFAULT_JSON_SERIALIZER.serialize(profile);
profile = Serializer.DEFAULT_JSON_SERIALIZER.deserialize(buffer, type);
User user = new User((UserProfile) profile);
session.addAttribute(PRINCIPAL, profile);
return user;
}
// Can't come here
return null;
}
示例14: degenerate
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
public Pair<String, Service> degenerate(final String accessTokenInput) {
final String accessTokenEncoded = new String(CompressionUtils.decodeBase64(accessTokenInput));
final String[] token = accessTokenEncoded.split(UserProfile.SEPARATOR);
if (token.length == 2) {
return new Pair(token[0], this.webApplicationServiceFactory.createService(token[1]));
}
throw new IllegalArgumentException("Access token received must include both the id and the requesting service");
}
示例15: doAuthentication
import org.pac4j.core.profile.UserProfile; //导入依赖的package包/类
@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
final ClientCredential clientCredentials = (ClientCredential) credential;
logger.debug("clientCredentials : {}", clientCredentials);
final Credentials credentials = clientCredentials.getCredentials();
final String clientName = credentials.getClientName();
logger.debug("clientName : {}", clientName);
// get client
final Client<Credentials, UserProfile> client = this.clients.findClient(clientName);
logger.debug("client : {}", client);
// web context
final ServletExternalContext servletExternalContext = (ServletExternalContext) ExternalContextHolder.getExternalContext();
final HttpServletRequest request = (HttpServletRequest) servletExternalContext.getNativeRequest();
final HttpServletResponse response = (HttpServletResponse) servletExternalContext.getNativeResponse();
final WebContext webContext = new J2EContext(request, response);
// get user profile
final UserProfile userProfile = client.getUserProfile(credentials, webContext);
logger.debug("userProfile : {}", userProfile);
if (userProfile != null) {
return createResult(clientCredentials, userProfile);
}
throw new FailedLoginException("Provider did not produce a user profile for: " + clientCredentials);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:30,代码来源:AbstractClientAuthenticationHandler.java