/** * @return the name */ public String getName() { return profile.getId(); }
@Override public String getId() { if (this.userProfile != null) { if (this.typedIdUsed) { return this.userProfile.getTypedId(); } return this.userProfile.getId(); } return NOT_YET_AUTHENTICATED + UUID.randomUUID().toString(); } }
@Override public String getId() { if (this.userProfile != null) { if (this.typedIdUsed) { return this.userProfile.getTypedId(); } return this.userProfile.getId(); } return null; }
public CasUserProfile(final UserProfile up, final Collection<String> adminRoles) { build(up.getId(), up.getAttributes()); setClientName(up.getClientName()); setLinkedId(up.getLinkedId()); setRemembered(up.isRemembered()); addRoles(up.getRoles()); addPermissions(up.getPermissions()); this.administrator = adminRoles.stream().anyMatch(r -> getRoles().contains(r)); }
val newPrincipal = this.principalFactory.createPrincipal(profile.getId(), profileAttributes); LOGGER.debug("Created final principal [{}] after filtering attributes based on [{}]", newPrincipal, registeredService); val metadata = new BasicCredentialMetaData(new BasicIdentifiableCredential(profile.getId())); val handlerResult = new DefaultAuthenticationHandlerExecutionResult(authenticator, metadata, newPrincipal, new ArrayList<>()); val scopes = CollectionUtils.toCollection(context.getRequest().getParameterValues(OAuth20Constants.SCOPE));
/** * 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; }
claims.setExpirationTime(expirationDate); claims.setIssuedAtToNow(); claims.setSubject(profile.getId());
.then(p -> { if (p.isPresent()) { ctx.getRequest().add(UserId.class, UserId.of(p.get().getId()));
/** * 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); }
final ProfileManager manager, final UserProfile uProfile) { val request = context.getRequest(); val clientId = uProfile.getId(); val redirectUri = request.getParameter(OAuth20Constants.REDIRECT_URI); val clientRegisteredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(this.servicesManager, clientId);