code: function (realm, permission, attributes) {
                  function check(parent, values) {
                      if (typeof parent === 'undefined') {
                          return false;
                      }
  
                      if (values.length === 0) {
                          var result = _.some(parent.$roles, function (role) {
                              return checkWithRoleFilter(currentRoles[realm][role] && currentRoles[realm][role].$unifiedRole);
                          }) && checkWithAttributeFilter(parent.$attributes);
  
                          if (typeof attributes === 'undefined') {
                              return result; // no attribute check, return the result as-is
                          } else {
                              return result && _.every(attributes, function (value, attribute) {
                                  return includes(parent.$attributes[attribute], '*') || includes(parent.$attributes[attribute], value);
                              });
                          }
                      }
  
                      return _.every(values.shift().split(','), function (value) {
                          if (value.indexOf('$') === 0) {
                              throw new Error('permissions cannot start with a $');
                          }
  
                          return check(parent['*'], values.slice(0)) || check(parent[value], values.slice(0));
                      });
                  }
  
                  var realmPermissions = currentPermissions[realm];
                  if (typeof realmPermissions === 'undefined') {
                      return false;
                  }
  
                  if (typeof permission === 'string') {
                      permission = permission.split(':');
                  }
  
                  return check(realmPermissions, permission.slice(0));
              }
docs: @ngdoc function
  @name w20CoreSecurity.service:AuthorizationService#hasPermission
  @methodOf w20CoreSecurity.service:AuthorizationService
  @param {String} realm The realm the check is made against.
  @param {String[]} permission The permission to check (as an array of strings or as a ":" delimited unique string).
  @param {Object} attributes The optional attributes object to further check on the permission.
  @returns {Boolean} True if the subject has the permission, false otherwise.
  
  @description
  
  Check if the currently authenticated subject has the specified permission with the specified attributes in the
  specified realm.