Browse Source

MINOR: Replaced unnecessary map and getOrElse with exists

Author: himani1 <1himani.arora@gmail.com>

Reviewers: Jason Gustafson <jason@confluent.io>

Closes #2035 from himani1/code_refactored
pull/2038/merge
himani1 8 years ago committed by Jason Gustafson
parent
commit
2965f50e0d
  1. 14
      core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala

14
core/src/main/scala/kafka/security/auth/SimpleAclAuthorizer.scala

@ -161,15 +161,15 @@ class SimpleAclAuthorizer extends Authorizer with Logging { @@ -161,15 +161,15 @@ class SimpleAclAuthorizer extends Authorizer with Logging {
}
private def aclMatch(session: Session, operations: Operation, resource: Resource, principal: KafkaPrincipal, host: String, permissionType: PermissionType, acls: Set[Acl]): Boolean = {
acls.find ( acl =>
acl.permissionType == permissionType
&& (acl.principal == principal || acl.principal == Acl.WildCardPrincipal)
&& (operations == acl.operation || acl.operation == All)
&& (acl.host == host || acl.host == Acl.WildCardHost)
).map { acl: Acl =>
acls.find { acl =>
acl.permissionType == permissionType &&
(acl.principal == principal || acl.principal == Acl.WildCardPrincipal) &&
(operations == acl.operation || acl.operation == All) &&
(acl.host == host || acl.host == Acl.WildCardHost)
}.exists { acl =>
authorizerLogger.debug(s"operation = $operations on resource = $resource from host = $host is $permissionType based on acl = $acl")
true
}.getOrElse(false)
}
}
override def addAcls(acls: Set[Acl], resource: Resource) {

Loading…
Cancel
Save