use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class RoleForRequestEvaluatorIntegrationTest method saveRoleAsUser.
private Exception saveRoleAsUser(IdmIdentityDto user, IdmRoleDto found1, String testDescription) {
try {
loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
IdmRoleDto fnd = roleService.get(found1.getId());
fnd.setDescription(testDescription);
roleService.save(fnd, IdmBasePermission.UPDATE);
} catch (Exception ex) {
return ex;
} finally {
logout();
}
return null;
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class RoleForRequestEvaluatorIntegrationTest method getRoleAsUser.
private Page<IdmRoleDto> getRoleAsUser(IdmIdentityDto user, IdmRoleDto role) {
try {
loginService.login(new LoginDto(user.getUsername(), new GuardedString(TEST_PWD)));
//
IdmRoleFilter rf = getRoleFilter("name", role.getName());
Page<IdmRoleDto> readRole = roleService.find(rf, null, IdmBasePermission.READ);
return readRole;
} finally {
logout();
}
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class RoleTransitiveEvaluatorsIntegrationTest method createIdentityWithRole.
private IdmIdentityDto createIdentityWithRole(boolean transitive) {
TEST_ROLE_ID = UUID.randomUUID();
loginAsAdmin(InitTestData.TEST_ADMIN_USERNAME);
IdmRoleDto role = helper.createRole(TEST_ROLE_ID, null);
IdmTreeNodeDto treeNode = helper.createTreeNode();
helper.createRoleTreeNode(role, treeNode, true);
// self policy
IdmAuthorizationPolicyDto readRolePolicy = new IdmAuthorizationPolicyDto();
readRolePolicy.setPermissions(IdmBasePermission.READ);
readRolePolicy.setRole(role.getId());
readRolePolicy.setGroupPermission(CoreGroupPermission.ROLE.getName());
readRolePolicy.setAuthorizableType(IdmRole.class.getCanonicalName());
readRolePolicy.setEvaluator(CodeableEvaluator.class);
readRolePolicy.getEvaluatorProperties().put(CodeableEvaluator.PARAMETER_IDENTIFIER, role.getId());
authorizationPolicyService.save(readRolePolicy);
if (transitive) {
// create transitive policies
IdmAuthorizationPolicyDto readRoleTreeNodePolicy = new IdmAuthorizationPolicyDto();
readRoleTreeNodePolicy.setRole(role.getId());
readRoleTreeNodePolicy.setGroupPermission(CoreGroupPermission.ROLETREENODE.getName());
readRoleTreeNodePolicy.setAuthorizableType(IdmRoleTreeNode.class.getCanonicalName());
readRoleTreeNodePolicy.setEvaluator(RoleTreeNodeByRoleEvaluator.class);
authorizationPolicyService.save(readRoleTreeNodePolicy);
//
IdmAuthorizationPolicyDto readAuthoritiesPolicy = new IdmAuthorizationPolicyDto();
readAuthoritiesPolicy.setRole(role.getId());
readAuthoritiesPolicy.setGroupPermission(CoreGroupPermission.AUTHORIZATIONPOLICY.getName());
readAuthoritiesPolicy.setAuthorizableType(IdmAuthorizationPolicy.class.getCanonicalName());
readAuthoritiesPolicy.setEvaluator(AuthorizationPolicyByRoleEvaluator.class);
authorizationPolicyService.save(readAuthoritiesPolicy);
}
// prepare identity
IdmIdentityDto identity = helper.createIdentity();
identity.setPassword(new GuardedString("heslo"));
identity = identityService.save(identity);
// assign role
helper.createIdentityRole(identity, role);
logout();
//
return identity;
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class DefaultRecaptchaRestTest method setup.
@Before
public void setup() throws Exception {
super.setup();
MockitoAnnotations.initMocks(this);
when(config.getSecretKey()).thenReturn(new GuardedString(TEST_SECRET_KEY));
}
use of eu.bcvsolutions.idm.core.security.api.domain.GuardedString in project CzechIdMng by bcvsolutions.
the class DefaultRecaptchaServiceUnitTest method testValid.
@Test()
public void testValid() {
RecaptchaResponse response = getRecaptchaResponse(TEST_HOSTNAME, true);
when(config.getSecretKey()).thenReturn(new GuardedString(TEST_SECRET_KEY));
when(template.postForEntity(anyString(), any(), eq(RecaptchaResponse.class))).thenReturn(getResponse(response, HttpStatus.OK));
RecaptchaResponse returned = service.checkRecaptcha(getRecaptchaRequest(TEST_REMOTE_IP, TEST_REQUEST));
//
verify(template).postForEntity(anyString(), any(), eq(RecaptchaResponse.class));
verifyNoMoreInteractions(template);
Assert.assertNotNull(returned);
Assert.assertEquals(returned.getHostname(), TEST_HOSTNAME);
}
Aggregations