Code example for Subject

Methods: getPrincipalssetReadOnly

0
            throw new SecurityException("Authentication manager failed", result.getCause());
        } 
        else if (AuthenticationStatus.SUCCESS.equals(result.getStatus()))
        { 
            final Subject subject = result.getSubject();
            subject.getPrincipals().add(new JMXPrincipal(username));
            subject.setReadOnly();
            return subject;
        } 
        else 
        { 
            throw new SecurityException(INVALID_CREDENTIALS);
        } 
    } 
 
} 
Connect your IDE to all the code out there  Get Codota for Java