use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondVisitor method addresses.
private SearchCond addresses(final String operator, final String left, final String right, final List<SCIMUserAddressConf> items) {
if (left.endsWith(".type") && "eq".equals(operator)) {
Optional<SCIMUserAddressConf> item = items.stream().filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst();
if (item.isPresent()) {
AttributeCond attributeCond = new AttributeCond();
attributeCond.setSchema(item.get().getFormatted());
attributeCond.setType(AttributeCond.Type.ISNOTNULL);
return SearchCond.getLeafCond(attributeCond);
}
} else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) {
List<SearchCond> orConds = new ArrayList<>();
items.forEach(item -> {
AttributeCond cond = new AttributeCond();
cond.setSchema(item.getFormatted());
cond.setExpression(StringUtils.strip(right, "\""));
orConds.add(setOperator(cond, operator));
});
if (!orConds.isEmpty()) {
return SearchCond.getOrCond(orConds);
}
}
return null;
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class CustomJWTSSOProvider method resolve.
@Transactional(readOnly = true)
@Override
public Pair<User, Set<SyncopeGrantedAuthority>> resolve(final JwtClaims jwtClaims) {
AttributeCond userIdCond = new AttributeCond();
userIdCond.setSchema("userId");
userIdCond.setType(AttributeCond.Type.EQ);
userIdCond.setExpression(jwtClaims.getSubject());
List<User> matching = searchDAO.search(SearchCond.getLeafCond(userIdCond), AnyTypeKind.USER);
if (matching.size() == 1) {
User user = matching.get(0);
Set<SyncopeGrantedAuthority> authorities = authDataAccessor.getAuthorities(user.getUsername());
return Pair.of(user, authorities);
}
return null;
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondVisitor method createAttributeCond.
public AttributeCond createAttributeCond(final String schema) {
AttributeCond attributeCond = null;
if (schemaEquals(Resource.User, "userName", schema)) {
attributeCond = new AnyCond();
attributeCond.setSchema("username");
} else if (resource == Resource.Group && schemaEquals(Resource.Group, "displayName", schema)) {
attributeCond = new AnyCond();
attributeCond.setSchema("name");
} else if (schemaEquals(null, "meta.created", schema)) {
attributeCond = new AnyCond();
attributeCond.setSchema("creationDate");
} else if (schemaEquals(null, "meta.lastModified", schema)) {
attributeCond = new AnyCond();
attributeCond.setSchema("lastChangeDate");
}
if (resource == Resource.User) {
if (conf.getUserConf() != null) {
if (conf.getUserConf().getName() != null) {
for (Map.Entry<String, String> entry : conf.getUserConf().getName().asMap().entrySet()) {
if (schemaEquals(Resource.User, "name." + entry.getKey(), schema)) {
attributeCond = new AttributeCond();
attributeCond.setSchema(entry.getValue());
}
}
}
for (Map.Entry<String, String> entry : conf.getUserConf().asMap().entrySet()) {
if (schemaEquals(Resource.User, entry.getKey(), schema)) {
attributeCond = new AttributeCond();
attributeCond.setSchema(entry.getValue());
}
}
for (SCIMUserAddressConf address : conf.getUserConf().getAddresses()) {
for (Map.Entry<String, String> entry : address.asMap().entrySet()) {
if (schemaEquals(Resource.User, "addresses." + entry.getKey(), schema)) {
attributeCond = new AttributeCond();
attributeCond.setSchema(entry.getValue());
}
}
}
}
if (conf.getEnterpriseUserConf() != null) {
for (Map.Entry<String, String> entry : conf.getEnterpriseUserConf().asMap().entrySet()) {
if (schemaEquals(Resource.EnterpriseUser, entry.getKey(), schema)) {
attributeCond = new AttributeCond();
attributeCond.setSchema(entry.getValue());
}
}
if (conf.getEnterpriseUserConf().getManager() != null && conf.getEnterpriseUserConf().getManager().getKey() != null) {
attributeCond = new AttributeCond();
attributeCond.setSchema(conf.getEnterpriseUserConf().getManager().getKey());
}
}
}
if (attributeCond == null) {
throw new IllegalArgumentException("Could not match " + schema + " for " + resource);
}
return attributeCond;
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondVisitor method complex.
private <E extends Enum<?>> SearchCond complex(final String operator, final String left, final String right, final List<SCIMComplexConf<E>> items) {
if (left.endsWith(".type")) {
Optional<SCIMComplexConf<E>> item = items.stream().filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst();
if (item.isPresent()) {
AttributeCond attributeCond = new AttributeCond();
attributeCond.setSchema(item.get().getValue());
attributeCond.setType(AttributeCond.Type.ISNOTNULL);
return SearchCond.getLeafCond(attributeCond);
}
} else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) {
List<SearchCond> orConds = new ArrayList<>();
items.forEach(item -> {
AttributeCond cond = new AttributeCond();
cond.setSchema(item.getValue());
cond.setExpression(StringUtils.strip(right, "\""));
orConds.add(setOperator(cond, operator));
});
if (!orConds.isEmpty()) {
return SearchCond.getOrCond(orConds);
}
}
return null;
}
use of org.apache.syncope.core.persistence.api.dao.search.AttributeCond in project syncope by apache.
the class SearchCondVisitor method visitATTR_PR.
@Override
public SearchCond visitATTR_PR(final SCIMFilterParser.ATTR_PRContext ctx) {
AttributeCond cond = createAttributeCond(ctx.ATTRNAME().getText());
cond.setType(AttributeCond.Type.ISNOTNULL);
return SearchCond.getLeafCond(cond);
}
Aggregations