public boolean commit() throws LoginException {
boolean result = delegate.commit();
Set<Principal> wrapped = new HashSet<Principal>();
for (Principal principal: localSubject.getPrincipals()) {
wrapped.add(new DomainPrincipal(loginDomainName, principal));
wrapped.add(new RealmPrincipal(realmName, loginDomainName, principal));
}
localSubject.getPrincipals().addAll(wrapped);
subject.getPrincipals().addAll(localSubject.getPrincipals());
subject.getPrivateCredentials().addAll(localSubject.getPrivateCredentials());