use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class MellonAutoLoginProcessorTest method getTenant.
private Tenant getTenant() {
AttributeDefinition firstNameDef = new AttributeDefinition(FIRST_NAME_ATTRIB_NAME);
AttributeDefinition lastNameDef = new AttributeDefinition(LAST_NAME_ATTRIB_NAME);
Tenant tenant = new Tenant();
tenant.setName(TENANT_NAME);
tenant.setSsoEnabled(true);
tenant.getAttributeDefinitions().add(firstNameDef);
tenant.getAttributeDefinitions().add(lastNameDef);
return tenant;
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantServiceImplTest method assertEqualAttributeDefinitions.
private void assertEqualAttributeDefinitions(List<AttributeDefinition> expected, List<AttributeDefinition> actual) {
assertNotNull(expected);
assertEquals(expected.size(), actual.size());
Iterator<AttributeDefinition> expectedIter = expected.iterator();
Iterator<AttributeDefinition> actualIter = actual.iterator();
while (expectedIter.hasNext()) {
AttributeDefinition expectedDefinition = expectedIter.next();
AttributeDefinition actualDefinition = actualIter.next();
assertEqualAttributeDefinitions(expectedDefinition, actualDefinition);
}
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class ProfileServiceImpl method filterAttributeIfReadNotAllowed.
protected void filterAttributeIfReadNotAllowed(Tenant tenant, Iterator<String> attributeNamesIter, List<AttributeDefinition> attributeDefinitions) throws PermissionException, AttributeNotDefinedException {
String tenantName = tenant.getName();
String attributeName = attributeNamesIter.next();
AttributeDefinition definition = findAttributeDefinition(attributeDefinitions, attributeName);
if (definition != null) {
if (!isAttributeActionAllowed(definition, AttributeAction.READ_ATTRIBUTE)) {
attributeNamesIter.remove();
}
} else {
throw new AttributeNotDefinedException(attributeName, tenantName);
}
}
use of org.craftercms.profile.api.AttributeDefinition in project profile by craftercms.
the class TenantServiceImplTest method getAttribute1Definition.
private AttributeDefinition getAttribute1Definition() {
AttributePermission permission = new AttributePermission();
permission.allow(AttributePermission.ANY_ACTION);
AttributeDefinition def = new AttributeDefinition();
def.setName(ATTRIB1_NAME);
def.setMetadata(Collections.<String, Object>singletonMap(LABEL_KEY, ATTRIB1_LABEL));
def.addPermission(permission);
return def;
}
use of org.craftercms.profile.api.AttributeDefinition in project engine by craftercms.
the class ProfileHeadersAuthenticationFilter method createProfileWithSsoInfo.
protected Profile createProfileWithSsoInfo(String username, Tenant tenant, HttpServletRequest request) throws ProfileException {
Map<String, Object> attributes = null;
List<AttributeDefinition> attributeDefinitions = tenant.getAttributeDefinitions();
String email = request.getHeader(getEmailHeaderName());
for (AttributeDefinition attributeDefinition : attributeDefinitions) {
String attributeName = attributeDefinition.getName();
String attributeValue = request.getHeader(getHeaderPrefix() + attributeName);
if (StringUtils.isNotEmpty(attributeValue)) {
if (attributes == null) {
attributes = new HashMap<>();
}
attributes.put(attributeName, attributeValue);
}
}
logger.info("Creating new profile with SSO info: username={}, email={}, tenant={}, attributes={}", username, email, tenant.getName(), attributes);
return profileService.createProfile(tenant.getName(), username, null, email, true, null, attributes, null);
}
Aggregations