protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(principalName); login(principal); }
@Override public MidPointUserProfilePrincipal getPrincipalByOid(String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointUserProfilePrincipal principal = userProfileService.getPrincipalByOid(oid); addFakeAuthorization(principal); return principal; } };
@Override public void updateUser(MidPointPrincipal principal) { userProfileService.updateUser(principal); }
@Override public <F extends FocusType, O extends ObjectType> PrismObject<F> resolveOwner(PrismObject<O> object) throws CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { return userProfileService.resolveOwner(object); }
protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(principalName); loginSuperUser(principal); }
userProfileService.updateUser(principal);
@Override public void refreshPrincipal(String oid) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { try { MidPointPrincipal principal = userProfileService.getPrincipalByOid(oid); securityContextManager.setupPreAuthenticatedSecurityContext(principal); } catch (Throwable e) { LOGGER.error("Cannot refresh authentication for user identified with" + oid); throw e; } }
protected void loginSuperUser(PrismObject<UserType> user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(user); loginSuperUser(principal); }
private void recordPasswordAuthenticationSuccess(MidPointPrincipal principal, ConnectionEnvironment connEnv, C passwordType, CredentialPolicyType passwordCredentialsPolicy) { Integer failedLogins = passwordType.getFailedLogins(); if (failedLogins != null && failedLogins > 0) { passwordType.setFailedLogins(0); } LoginEventType event = new LoginEventType(); event.setTimestamp(clock.currentTimeXMLGregorianCalendar()); event.setFrom(connEnv.getRemoteHostAddress()); passwordType.setPreviousSuccessfulLogin(passwordType.getLastSuccessfulLogin()); passwordType.setLastSuccessfulLogin(event); ActivationType activation = principal.getUser().getActivation(); if (activation != null) { activation.setLockoutStatus(LockoutStatusType.NORMAL); activation.setLockoutExpirationTimestamp(null); } userProfileService.updateUser(principal); recordAuthenticationSuccess(principal, connEnv); }
@Override public MidPointUserProfilePrincipal getPrincipal(PrismObject<UserType> user, AuthorizationTransformer authorizationLimiter, OperationResult result) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointUserProfilePrincipal principal = userProfileService.getPrincipal(user); addFakeAuthorization(principal); return principal; }
@Override public MidPointUserProfilePrincipal getPrincipal(String username) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointUserProfilePrincipal principal = userProfileService.getPrincipal(username); addFakeAuthorization(principal); return principal; }
protected void login(PrismObject<UserType> user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(user); login(principal); }
protected void assertAuthorizations(PrismObject<UserType> user, String... expectedAuthorizations) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(user); assertNotNull("No principal for "+user, principal); assertAuthorizations(principal, expectedAuthorizations); }
protected void assertNoAuthorizations(PrismObject<UserType> user) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(user); assertNotNull("No principal for "+user, principal); assertNoAuthorizations(principal); }
@Test public void test000Sanity() throws Exception { final String TEST_NAME = "test000Sanity"; TestUtil.displayTestTitle(TEST_NAME); assertNotNull(getAuthenticationEvaluator()); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); assertPrincipalJack(principal); }
principal = userProfileService.getPrincipal(enteredUsername); } catch (ObjectNotFoundException e) { recordAuthenticationFailure(enteredUsername, connEnv, "no user");
@Test public void test010GetUserAdministrator() throws Exception { final String TEST_NAME = "test010GetUserAdministrator"; displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN MidPointPrincipal principal = userProfileService.getPrincipal(USER_ADMINISTRATOR_USERNAME); // THEN display("Administrator principal", principal); assertEquals("Wrong number of authorizations", 1, principal.getAuthorities().size()); assertHasAuthotizationAllow(principal.getAuthorities().iterator().next(), AuthorizationConstants.AUTZ_ALL_URL); assertAuthorized(principal, AUTZ_LOOT_URL); assertAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test052PrincipalJackDraft() throws Exception { final String TEST_NAME = "test052AutzJackDraft"; displayTestTitle(TEST_NAME); // GIVEN // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); // THEN displayThen(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertNotAuthorized(principal, AUTZ_GAMBLE_URL); assertNotAuthorized(principal, AUTZ_APPARATE_URL); }
@Test public void test050GetUserJack() throws Exception { final String TEST_NAME = "test050GetUserJack"; displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); // THEN assertNoAuthentication(); assertJack(principal); assertTrue("Unexpected authorizations", principal.getAuthorities().isEmpty()); assertNoAuthentication(); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertNoAuthentication(); }
@Test public void test092PrincipalJackDefaultActive() throws Exception { final String TEST_NAME = "test092PrincipalJackDefaultActive"; displayTestTitle(TEST_NAME); // GIVEN // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); // THEN displayThen(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); assertAuthorized(principal, AUTZ_GAMBLE_URL); assertAuthorized(principal, AUTZ_APPARATE_URL); // Forced assignment not specified for active lifecycle state assertNotAuthorized(principal, AUTZ_PIT_BOSS_URL); assertNotAuthorized(principal, AUTZ_CROUPIER_URL); }