Example usage for org.springframework.security.core GrantedAuthority equals

List of usage examples for org.springframework.security.core GrantedAuthority equals

Introduction

In this page you can find the example usage for org.springframework.security.core GrantedAuthority equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:org.springmodules.validation.valang.functions.InRoleFunction.java

protected Object doGetResult(Object target) {

    Object role = getArguments()[0].getResult(target);

    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (authentication == null) {
        return Boolean.FALSE;
    }//from   w ww .  j a v  a 2s  .  c  o  m

    Collection<GrantedAuthority> authorities = authentication.getAuthorities();

    for (GrantedAuthority grantedAuthority : authorities) {
        if (grantedAuthority.equals(role)) {
            return Boolean.TRUE;
        }
    }

    return Boolean.FALSE;
}