private static long getSessionId() throws JGDIException {
Subject sub = Subject.getSubject(AccessController.getContext());
if (sub != null) {
Set<JGDIPrincipal> ps = sub.getPrincipals(JGDIPrincipal.class);
if (!ps.isEmpty()) {
JGDIPrincipal p = ps.iterator().next();
return p.getSessionId();
}
}
throw new JGDIException("no active session found in subject " + sub);
}