/** * Semi-shallow clone. */ public MidPointUserProfilePrincipal clone() { MidPointUserProfilePrincipal clone = new MidPointUserProfilePrincipal(this.getUser()); copyValues(clone); return clone; }
public void compileUserProfile(MidPointUserProfilePrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration, AuthorizationTransformer authorizationTransformer, Task task, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { principal.setApplicableSecurityPolicy(securityHelper.locateSecurityPolicy(principal.getUser().asPrismObject(), systemConfiguration, task, result)); Collection<Authorization> authorizations = principal.getAuthorities(); List<AdminGuiConfigurationType> adminGuiConfigurations = new ArrayList<>(); collect(adminGuiConfigurations, principal, systemConfiguration, authorizationTransformer, task, result); CompiledUserProfile compiledUserProfile = compileUserProfile(adminGuiConfigurations, systemConfiguration, task, result); principal.setCompiledUserProfile(compiledUserProfile); }
protected CompiledUserProfileAsserter<Void> assertCompiledUserProfile(MidPointPrincipal principal) { if (!(principal instanceof MidPointUserProfilePrincipal)) { fail("Expected MidPointUserProfilePrincipal, but got "+principal.getClass()); } CompiledUserProfile compiledUserProfile = ((MidPointUserProfilePrincipal)principal).getCompiledUserProfile(); CompiledUserProfileAsserter<Void> asserter = new CompiledUserProfileAsserter<>(compiledUserProfile, null, "in principal "+principal); initializeAsserter(asserter); asserter.display(); return asserter; }
@Override public MidPointUserProfilePrincipal getPrincipal(PrismObject<UserType> user, AuthorizationTransformer authorizationTransformer, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { if (user == null) { return null; } PrismObject<SystemConfigurationType> systemConfiguration = getSystemConfiguration(result); LifecycleStateModelType lifecycleModel = getLifecycleModel(user, systemConfiguration); userComputer.recompute(user, lifecycleModel); MidPointUserProfilePrincipal principal = new MidPointUserProfilePrincipal(user.asObjectable()); initializePrincipalFromAssignments(principal, systemConfiguration, authorizationTransformer); return principal; }
private void collect(List<AdminGuiConfigurationType> adminGuiConfigurations, MidPointUserProfilePrincipal principal, PrismObject<SystemConfigurationType> systemConfiguration, AuthorizationTransformer authorizationTransformer, Task task, OperationResult result) throws SchemaException { UserType userType = principal.getUser(); LensContext<UserType> lensContext = createAuthenticationLensContext(userType.asPrismObject(), systemConfiguration);
@NotNull @Override public CompiledUserProfile getCompiledUserProfile(Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = null; try { principal = securityContextManager.getPrincipal(); } catch (SecurityViolationException e) { LOGGER.warn("Security violation while getting principlal to get GUI config: {}", e.getMessage(), e); } if (principal == null || !(principal instanceof MidPointUserProfilePrincipal)) { // May be used for unathenticated user, error pages and so on return userProfileCompiler.getGlobalCompiledUserProfile(task, parentResult); } else { return ((MidPointUserProfilePrincipal)principal).getCompiledUserProfile(); } }