@Override public String getAsString(FacesContext context, UIComponent component, Object value) { return ((OAuthSession) value).getId(); } }
@Override public OAuthSession get(String id) { for (OAuthSession session : activeSessions) { if (id.equals(session.getId())) return session; } return null; }
@Override public OAuthSession getOauthSession(String sid) { if (sid != null && !sid.isEmpty()) { for (OAuthSession session : getAllOauthSessions()) { if (session.getId().equals(sid)) { return session; } } } return null; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof OAuthSession)) return false; OAuthSession other = (OAuthSession) obj; if (userProfile != null) return userProfile.equals(other.userProfile); else return id.equals(other.getId()); }
@Override public OAuthAppSettings tune(OAuthAppSettings toTune) { return new SimpleOAuthAppSettingsBuilder() .readFromSettings(toTune) .callback(new FacesUrlTransformer(toTune.getCallback()) .appendParamIfNecessary(AgoravaConstants.SESSIONID_PARAM, session.getId()).getUrl()) .build(); } }
/** * Configure this builder with an existing {@link org.agorava.api.oauth.OAuthSession}. Convenient to clone a session * or to create an unproxified version of a session * * @param session the session to read values from * @return this builder */ public Builder readFromOAuthSession(OAuthSession session) { qualifier(session.getServiceQualifier()) .requestToken(session.getRequestToken()) .accessToken(session.getAccessToken()) .verifier(session.getVerifier()) .userProfile(session.getUserProfile()) .repo(session.getRepo()) .id(session.getId()); return this; }