public String generateRowLevelSecurityConstraint( LogicalModel model ) {
RowLevelSecurity rls = model.getRowLevelSecurity();
if ( rls == null || rls.getType() == RowLevelSecurity.Type.NONE ) {
return null;
}
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if ( auth == null ) {
logger.info( Messages.getInstance().getString( "SecurityAwareCwmSchemaFactory.INFO_AUTH_NULL_CONTINUE" ) ); //$NON-NLS-1$
return "FALSE()"; //$NON-NLS-1$
}
String username = auth.getName();
HashSet<String> roles = null;
roles = new HashSet<String>();
for ( GrantedAuthority role : auth.getAuthorities() ) {
roles.add( role.getAuthority() );
}
RowLevelSecurityHelper helper = new SessionAwareRowLevelSecurityHelper();
return helper.getOpenFormulaSecurityConstraint( rls, username, new ArrayList<String>( roles ) );