protected void login(String principalName) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(principalName); login(principal); }
protected void loginSuperUser(String principalName) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(principalName); loginSuperUser(principal); }
protected void loginSuperUser(PrismObject<UserType> user) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { MidPointPrincipal principal = userProfileService.getPrincipal(user); loginSuperUser(principal); }
@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); }
@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); }
@Test public void test062PrincipalJackProposed() throws Exception { final String TEST_NAME = "test062PrincipalJackProposed"; displayTestTitle(TEST_NAME); // GIVEN // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); // THEN displayThen(TEST_NAME); assertNotAuthorized(principal, AUTZ_COMMAND_URL); // Although we are in the proposed lifecycle and assignments would not be active by default // the proposed lifecycle is forcing activation to enabled. Therefore also assignments are // considered active. Their authorizations should be applied to principal. assertAuthorized(principal, AUTZ_GAMBLE_URL); assertAuthorized(principal, AUTZ_APPARATE_URL); // Forced assignment as specified in proposed lifecycle model assertAuthorized(principal, AUTZ_PIT_BOSS_URL); // and induced authz from pit boss assertAuthorized(principal, AUTZ_CROUPIER_URL); }
@Test public void test111GuybrushRoleCaptain() throws Exception { final String TEST_NAME = "test111GuybrushRoleCaptain"; displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_CAPTAIN_OID, task, result); resetAuthentication(); // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_GUYBRUSH_USERNAME); // THEN displayThen(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 3, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test119GuybrushUnassignRoles() throws Exception { final String TEST_NAME = "test119GuybrushUnassignRoles"; displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); unassignRole(USER_JACK_OID, ROLE_PIRATE_OID, task, result); unassignRole(USER_JACK_OID, ROLE_CAPTAIN_OID, task, result); resetAuthentication(); // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_JACK_USERNAME); // THEN displayThen(TEST_NAME); assertEquals("Wrong number of authorizations", 0, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test110GuybrushRoleNicePirate() throws Exception { final String TEST_NAME = "test110GuybrushRoleNicePirate"; displayTestTitle(TEST_NAME); // GIVEN login(USER_ADMINISTRATOR_USERNAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); assignRole(USER_GUYBRUSH_OID, ROLE_NICE_PIRATE_OID, task, result); resetAuthentication(); // WHEN displayWhen(TEST_NAME); MidPointPrincipal principal = userProfileService.getPrincipal(USER_GUYBRUSH_USERNAME); // THEN displayThen(TEST_NAME); display("Principal guybrush", principal); assertEquals("Wrong number of authorizations", 2, principal.getAuthorities().size()); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test052GetUserGuybrush() throws Exception { final String TEST_NAME = "test052GetUserGuybrush"; displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN MidPointPrincipal principal = userProfileService.getPrincipal(USER_GUYBRUSH_USERNAME); // THEN display("Principal guybrush", principal); assertEquals("wrong username", USER_GUYBRUSH_USERNAME, principal.getUsername()); assertEquals("wrong oid", USER_GUYBRUSH_OID, principal.getOid()); assertTrue("Unexpected authorizations", principal.getAuthorities().isEmpty()); display("User in principal guybrush", principal.getUser().asPrismObject()); principal.getUser().asPrismObject().checkConsistence(true, true); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test051GetUserBarbossa() throws Exception { final String TEST_NAME = "test051GetUserBarbossa"; displayTestTitle(TEST_NAME); resetAuthentication(); // WHEN MidPointPrincipal principal = userProfileService.getPrincipal(USER_BARBOSSA_USERNAME); // THEN display("Principal barbossa", principal); assertNotNull("No principal for username "+USER_BARBOSSA_USERNAME, principal); assertEquals("wrong username", USER_BARBOSSA_USERNAME, principal.getUsername()); assertEquals("wrong oid", USER_BARBOSSA_OID, principal.getOid()); assertTrue("Unexpected authorizations", principal.getAuthorities().isEmpty()); display("User in principal barbossa", principal.getUser().asPrismObject()); principal.getUser().asPrismObject().checkConsistence(true, true); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); }
@Test public void test062GuybrushConditionalRoleUnassign() throws Exception { final String TEST_NAME = "test062GuybrushConditionalRoleUnassign"; displayTestTitle(TEST_NAME); login(USER_ADMINISTRATOR_USERNAME); unassignRole(USER_GUYBRUSH_OID, ROLE_CONDITIONAL_OID); resetAuthentication(); // WHEN MidPointPrincipal principal = userProfileService.getPrincipal(USER_GUYBRUSH_USERNAME); // THEN display("Principal guybrush", principal); assertEquals("wrong username", USER_GUYBRUSH_USERNAME, principal.getUsername()); assertEquals("wrong oid", USER_GUYBRUSH_OID, principal.getOid()); assertTrue("Unexpected authorizations", principal.getAuthorities().isEmpty()); display("User in principal guybrush", principal.getUser().asPrismObject()); principal.getUser().asPrismObject().checkConsistence(true, true); assertNotAuthorized(principal, AUTZ_LOOT_URL); assertNotAuthorized(principal, AUTZ_COMMAND_URL); }