gluu
静的公開メンバ関数 | 静的非公開メンバ関数 | 静的非公開変数類 | 全メンバ一覧
org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil クラス
org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil 連携図
Collaboration graph

静的公開メンバ関数

static CompValueType getCompValueType (ScimFilterParser.CompvalueContext compValueCtx)
 
static String checkFilterConsistency (String attribute, Type attrType, CompValueType type, ScimOperator operator)
 
static void logOperatorInconsistency (String operator, String type, String attrname)
 
static String getOperatorInconsistencyError (String operator, String type, String attrname)
 
static String preprocess (String filther, Class<? extends BaseScimResource > clazz) throws Exception
 
static Pair< String, Boolean > getLdapAttributeOfResourceAttribute (String path, Class<? extends BaseScimResource > resourceClass)
 

静的非公開メンバ関数

static String checkTypeConsistency (String attribute, Type attrType, CompValueType type)
 
static String getTypeInconsistencyError (String attrname, String type1, String type2)
 
static int startIndexParentAttr (String str)
 
static String applyPrefix (String parent, String innerExpr, Class<? extends BaseScimResource > clazz)
 
static String removeBrackets (String filther, Class<? extends BaseScimResource > clazz) throws Exception
 

静的非公開変数類

static Logger log = LogManager.getLogger(FilterUtil.class)
 

詳解

著者
Val Pecaoco Updated by jgomer on 2017-12-12.

関数詳解

◆ applyPrefix()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.applyPrefix ( String  parent,
String  innerExpr,
Class<? extends BaseScimResource clazz 
)
inlinestaticprivate
131  {
132 
133  SortedSet<String> validPaths= IntrospectUtil.allAttrs.get(clazz);
134  //Find all those starting with parent
135  for (String path : validPaths.tailSet(parent)){
136  if (path.startsWith(parent)){
137  String subAttr=path.substring(parent.length());
138  if (subAttr.startsWith(".")){
139  subAttr=subAttr.substring(1);
140  //add parent prefix to all occurrences of subAttr in the expression
141  innerExpr=innerExpr.replaceAll(subAttr, parent + "." + subAttr);
142  }
143  }
144  else
145  break;
146  }
147  return innerExpr;
148  }

◆ checkFilterConsistency()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.checkFilterConsistency ( String  attribute,
Type  attrType,
CompValueType  type,
ScimOperator  operator 
)
inlinestatic
79  {
80 
81  String error=null;
82 
83  if (type.equals(CompValueType.NULL)) {
84  if (!operator.equals(ScimOperator.EQUAL) && !operator.equals(ScimOperator.NOT_EQUAL)) {
85  //Only makes sense if operator is eq or neq
86  error=String.format("Cannot use null in a filter with operator '%s'", operator.getValue());
87  log.error("checkFilterConsistency. {}", error);
88  }
89  }
90  else
91  error = checkTypeConsistency(attribute, attrType, type);
92 
93  return error;
94 
95  }
static Logger log
Definition: FilterUtil.java:29
static String checkTypeConsistency(String attribute, Type attrType, CompValueType type)
Definition: FilterUtil.java:51

◆ checkTypeConsistency()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.checkTypeConsistency ( String  attribute,
Type  attrType,
CompValueType  type 
)
inlinestaticprivate
51  {
52 
53  boolean pass;
54  String error=null;
55 
56  if (Type.STRING.equals(attrType) || Type.REFERENCE.equals(attrType) || Type.DATETIME.equals(attrType))
57  pass=type.equals(CompValueType.STRING); //Here STRING refers to ScimFilter.g4 rules
58  else
59  if (Type.INTEGER.equals(attrType) || Type.DECIMAL.equals(attrType))
60  pass=type.equals(CompValueType.NUMBER); //Here NUMBER refers to ScimFilter.g4 rule
61  else
62  if (Type.BOOLEAN.equals(attrType))
63  pass=type.equals(CompValueType.BOOLEAN); //Here BOOLEAN refers to ScimFilter.g4 rule
64  else {
65  error=String.format("Filtering over attributes of type '%s' is not supported", attrType);
66  log.error("checkTypeConsistency. {}", error);
67  return error;
68  }
69 
70  if (!pass) {
71  error=getTypeInconsistencyError(attribute, attrType.toString(), type.toString());
72  log.error("checkTypeConsistency. {}", error);
73  }
74 
75  return error;
76 
77  }
static String getTypeInconsistencyError(String attrname, String type1, String type2)
Definition: FilterUtil.java:105
static Logger log
Definition: FilterUtil.java:29

◆ getCompValueType()

static CompValueType org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.getCompValueType ( ScimFilterParser.CompvalueContext  compValueCtx)
inlinestatic
31  {
32 
33  CompValueType valueType=null;
34 
35  if (compValueCtx.BOOLEAN()!=null)
36  valueType=CompValueType.BOOLEAN;
37  else
38  if (compValueCtx.NUMBER()!=null)
39  valueType=CompValueType.NUMBER;
40  else
41  if (compValueCtx.NULL()!=null)
42  valueType=CompValueType.NULL;
43  else
44  if (compValueCtx.STRING()!=null)
45  valueType = CompValueType.STRING;
46 
47  return valueType;
48 
49  }
do if[-f "$CONFIG"]
Definition: oxd-https-extension.init.d:165

◆ getLdapAttributeOfResourceAttribute()

static Pair<String, Boolean> org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.getLdapAttributeOfResourceAttribute ( String  path,
Class<? extends BaseScimResource resourceClass 
)
inlinestatic
189  {
190 
191  log.trace("getLdapAttributeOfResourceAttribute. path={}", path);
192  boolean inner=false;
193  Map<String, String> refs=IntrospectUtil.storeRefs.get(resourceClass);
194  String ldapAttribute=null;
195 
196  while (ldapAttribute==null && path.length()>0){
197  ldapAttribute=refs.get(path);
198 
199  if (ldapAttribute==null) {
200  int i = path.indexOf(".");
201  inner = i >= 0;
202  i = (i == -1) ? 0 : i;
203  path = path.substring(0, i);
204  }
205  }
206  return new Pair<String, Boolean>(ldapAttribute, inner);
207 
208  }
static Logger log
Definition: FilterUtil.java:29

◆ getOperatorInconsistencyError()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.getOperatorInconsistencyError ( String  operator,
String  type,
String  attrname 
)
inlinestatic
101  {
102  return String.format("Operator '%s' is not consistent with type '%s' of attribute %s", operator, type, attrname);
103  }

◆ getTypeInconsistencyError()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.getTypeInconsistencyError ( String  attrname,
String  type1,
String  type2 
)
inlinestaticprivate
105  {
106  return String.format("Attribute %s is of type '%s' but compare value supplied is of type '%s'", attrname, type1, type2);
107  }

◆ logOperatorInconsistency()

static void org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.logOperatorInconsistency ( String  operator,
String  type,
String  attrname 
)
inlinestatic
97  {
98  log.error(getOperatorInconsistencyError(operator, type, attrname));
99  }
static Logger log
Definition: FilterUtil.java:29
static String getOperatorInconsistencyError(String operator, String type, String attrname)
Definition: FilterUtil.java:101

◆ preprocess()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.preprocess ( String  filther,
Class<? extends BaseScimResource clazz 
) throws Exception
inlinestatic
引数
filtherNon-empty string
戻り値
114  {
115 
116  filther = filther.replaceAll(ScimResourceUtil.getDefaultSchemaUrn(clazz) + ":", "");
117  filther = removeBrackets(filther, clazz);
118  log.debug("Filter transformed to: {}", filther);
119 
120  return filther;
121 
122  }
static String removeBrackets(String filther, Class<? extends BaseScimResource > clazz)
Definition: FilterUtil.java:158
static Logger log
Definition: FilterUtil.java:29

◆ removeBrackets()

static String org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.removeBrackets ( String  filther,
Class<? extends BaseScimResource clazz 
) throws Exception
inlinestaticprivate

Transalte a filter string such as emails[type eq "work" and value co "@example.com"] or ims[type eq "xmpp" and value co "@foo.com"] into (emails.type eq "work" and emails.value co "@example.com") or (ims.type eq "xmpp" and ims.value co "@foo.com")

引数
filther
clazz
戻り値
例外
Exception
158  {
159 
160  //Remove brackets: [] and adjust by prefixing accordingly
161  int j, offset =0;
162  int i= filther.indexOf("[");
163  StringBuilder sb=new StringBuilder();
164 
165  while (i!=-1) {
166  //find closing bracket:
167  j= filther.indexOf("]", i);
168  if (j==-1)
169  throw new Exception("Invalid filter: closing bracket ']' expected");
170 
171  String str= filther.substring(i+1, j);
172  int k=startIndexParentAttr(filther.substring(offset, i)) + offset;
173  if (k==i)
174  throw new Exception("Invalid filter: no parent attrPath found before opening braket '['");
175 
176  sb.append(filther.substring(offset, k)).append("(");
177  sb.append(applyPrefix(filther.substring(k,i), str, clazz));
178  sb.append(")");
179 
180  offset=j+1;
181  i= filther.indexOf("[", offset);
182  }
183  //"Paste" the remaining unprocessed part
184  sb.append(filther.substring(offset));
185  return sb.toString();
186 
187  }
static int startIndexParentAttr(String str)
Definition: FilterUtil.java:124
static String applyPrefix(String parent, String innerExpr, Class<? extends BaseScimResource > clazz)
Definition: FilterUtil.java:131

◆ startIndexParentAttr()

static int org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.startIndexParentAttr ( String  str)
inlinestaticprivate
124  {
125 
126  int i;
127  for (i=str.length(); i>0 && Pattern.matches("\\w", str.substring(i-1, i)); i--);
128  return i;
129  }

メンバ詳解

◆ log

Logger org.gluu.oxtrust.service.antlr.scimFilter.util.FilterUtil.log = LogManager.getLogger(FilterUtil.class)
staticprivate

このクラス詳解は次のファイルから抽出されました: