Check if an identity matches this filter.
(&self, identity: &Identity, has_secret: bool)
| 302 | |
| 303 | /// Check if an identity matches this filter. |
| 304 | fn matches(&self, identity: &Identity, has_secret: bool) -> bool { |
| 305 | if let Some(ref usage) = self.usage { |
| 306 | if &identity.usage != usage { |
| 307 | return false; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | if let Some(ref identity_type) = self.identity_type { |
| 312 | if &identity.identity_type != identity_type { |
| 313 | return false; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | if let Some(ref pattern) = self.name_pattern { |
| 318 | if !identity |
| 319 | .name |
| 320 | .to_lowercase() |
| 321 | .contains(&pattern.to_lowercase()) |
| 322 | { |
| 323 | return false; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if let Some(require_secret) = self.has_secret_key { |
| 328 | if has_secret != require_secret { |
| 329 | return false; |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | if self.valid_only && !identity.is_valid() { |
| 334 | return false; |
| 335 | } |
| 336 | |
| 337 | true |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /// Identity store for persisting and managing multiple identities. |