Code example for Subject

Methods: doAs

0
        for (int i = 0; i < 1000; i++) {
            Subject.doAs(
                subject,
                new PrivilegedAction() {
                    public Object run() {
                        return Subject.doAs(
                            new Subject(true,
                                        Collections.singleton(
                                            new X500Principal("CN=Claire")),
                                        Collections.EMPTY_SET,
                                        Collections.EMPTY_SET),
                            new PrivilegedAction() {
                                public Object run() {
                                    return null; 
                                } 
                            }); 
                    } 
                }); 
        } 
    } 
Connect your IDE to all the code out there  Get Codota for Java