protected static SecurityContext createSC(String user, String... roles) {
        final Subject subject = new Subject();

        final Principal principal = new SimplePrincipal(user);
        subject.getPrincipals().add(principal);

        if (roles != null) {
            for (final String role : roles) {
                subject.getPrincipals().add(new SimplePrincipal(role));
            }
        }
        return new DefaultSecurityContext(principal, subject);
    }
protected static SecurityContext createSC ( String user , String ... roles ) { final Subject subject = new Subject ( ) ; final Principal principal = new SimplePrincipal ( user ) ; subject . getPrincipals ( ) . add ( principal ) ; if ( roles != null ) { for ( final String role : roles ) { subject . getPrincipals ( ) . add ( new SimplePrincipal ( role ) ) ; } } return new DefaultSecurityContext ( principal , subject ) ; }
Create a {@link SecurityContext} to return to the provider

@param user  the user principal
@param roles the roles of the user
@return the {@link SecurityContext}