public Share createShare(Principal principal, boolean enabled, long timeToLive, String eventType, String description, long groupId) { Share share = newShare(); define(share, UUID.randomUUID().toString(), description, System .currentTimeMillis(), defaultTimeToIdle, timeToLive, eventType, "Share", null); share.setGroup(new ExperimenterGroup(groupId, false)); share.setActive(enabled); share.setData(new byte[] {}); share.setItemCount(0L); CreationRequest req = new CreationRequest(); req.principal = principal; return (Share) createSession(req, share); }
public Session createFromRequest(CreationRequest request) { // If credentials exist as session, then return that if (request.credentials != null) { try { SessionContext context = cache .getSessionContext(request.credentials); if (context != null) { context.count().increment(); return context.getSession(); // EARLY EXIT! } } catch (SessionException se) { // oh well. } // Though trusted values, if we receive a null principal, not ok; boolean ok = request.principal == null ? false : executeCheckPassword( request.principal, request.credentials); if (!ok) { log.warn("Failed to authenticate: " + request.principal); throw new AuthenticationException("Authentication exception."); } } // authentication checked. Now delegating to the admin method (no pass) Session session = new Session(); define(session, UUID.randomUUID().toString(), "Initial message.", System.currentTimeMillis(), request); return createSession(request, session); }