private void openSession(String applicationId, List<String> permissions, SessionLoginBehavior behavior, int activityCode, SessionAuthorizationType authType) { if (sessionTracker != null) { Session currentSession = sessionTracker.getSession(); if (currentSession == null || currentSession.getState().isClosed()) { Session session = new Session.Builder(getActivity()).setApplicationId(applicationId).build(); Session.setActiveSession(session); currentSession = session; } if (!currentSession.isOpened()) { Session.OpenRequest openRequest = new Session.OpenRequest(this). setPermissions(permissions). setLoginBehavior(behavior). setRequestCode(activityCode); if (SessionAuthorizationType.PUBLISH.equals(authType)) { currentSession.openForPublish(openRequest); } else { currentSession.openForRead(openRequest); } } } }
private void requestNewPermissions(NewPermissionsRequest newPermissionsRequest, SessionAuthorizationType authType) { validatePermissions(newPermissionsRequest, authType); validateLoginBehavior(newPermissionsRequest); if (newPermissionsRequest != null) { synchronized (this.lock) { if (pendingAuthorizationRequest != null) { throw new UnsupportedOperationException( "Session: an attempt was made to request new permissions for a session that has a pending request."); } if (state.isOpened()) { pendingAuthorizationRequest = newPermissionsRequest; } else if (state.isClosed()) { throw new UnsupportedOperationException( "Session: an attempt was made to request new permissions for a session that has been closed."); } else { throw new UnsupportedOperationException( "Session: an attempt was made to request new permissions for a session that is not currently open."); } } newPermissionsRequest.setValidateSameFbidAsToken(getAccessToken()); addCallback(newPermissionsRequest.getCallback()); authorize(newPermissionsRequest); } }
private void validatePermissions(AuthorizationRequest request, SessionAuthorizationType authType) { if (request == null || Utility.isNullOrEmpty(request.getPermissions())) { if (SessionAuthorizationType.PUBLISH.equals(authType)) { throw new FacebookException("Cannot request publish or manage authorization with no permissions."); } return; // nothing to check } for (String permission : request.getPermissions()) { if (isPublishPermission(permission)) { if (SessionAuthorizationType.READ.equals(authType)) { throw new FacebookException( String.format( "Cannot pass a publish or manage permission (%s) to a request for read authorization", permission)); } } else { if (SessionAuthorizationType.PUBLISH.equals(authType)) { Log.w(TAG, String.format( "Should not pass a read permission (%s) to a request for publish or manage authorization", permission)); } } } }
private void requestNewPermissions(NewPermissionsRequest paramNewPermissionsRequest, SessionAuthorizationType paramSessionAuthorizationType) { validatePermissions(paramNewPermissionsRequest, paramSessionAuthorizationType); validateLoginBehavior(paramNewPermissionsRequest); if (paramNewPermissionsRequest != null) { synchronized (this.lock) { if (this.pendingAuthorizationRequest != null) throw new UnsupportedOperationException("Session: an attempt was made to request new permissions for a session that has a pending request."); if (this.state.isOpened()) { this.pendingAuthorizationRequest = paramNewPermissionsRequest; } else { if (this.state.isClosed()) throw new UnsupportedOperationException("Session: an attempt was made to request new permissions for a session that has been closed."); throw new UnsupportedOperationException("Session: an attempt was made to request new permissions for a session that is not currently open."); } } paramNewPermissionsRequest.setValidateSameFbidAsToken(getAccessToken()); addCallback(paramNewPermissionsRequest.getCallback()); authorize(paramNewPermissionsRequest); } }
private void validatePermissions(AuthorizationRequest paramAuthorizationRequest, SessionAuthorizationType paramSessionAuthorizationType) { if ((paramAuthorizationRequest == null) || (Utility.isNullOrEmpty(paramAuthorizationRequest.getPermissions()))) { if (SessionAuthorizationType.PUBLISH.equals(paramSessionAuthorizationType)) throw new FacebookException("Cannot request publish or manage authorization with no permissions."); return; } Iterator localIterator = paramAuthorizationRequest.getPermissions().iterator(); while (localIterator.hasNext()) { String str = (String)localIterator.next(); if (isPublishPermission(str)) { if (SessionAuthorizationType.READ.equals(paramSessionAuthorizationType)) throw new FacebookException(String.format("Cannot pass a publish or manage permission (%s) to a request for read authorization", new Object[] { str })); } else SessionAuthorizationType.PUBLISH.equals(paramSessionAuthorizationType); } }
private void requestNewPermissions(NewPermissionsRequest newPermissionsRequest, SessionAuthorizationType authType) { validatePermissions(newPermissionsRequest, authType); validateLoginBehavior(newPermissionsRequest); if (newPermissionsRequest != null) { synchronized (this.lock) { if (pendingRequest != null) { throw new UnsupportedOperationException( "Session: an attempt was made to request new permissions for a session that has a pending request."); } switch (this.state) { case OPENED: case OPENED_TOKEN_UPDATED: pendingRequest = newPermissionsRequest; break; default: throw new UnsupportedOperationException( "Session: an attempt was made to request new permissions for a session that is not currently open."); } } newPermissionsRequest.setValidateSameFbidAsToken(getAccessToken()); authorize(newPermissionsRequest); } }
public void setReadPermissions(List<String> permissions, Session session) { if (SessionAuthorizationType.PUBLISH.equals(authorizationType)) { throw new UnsupportedOperationException( "Cannot call setReadPermissions after setPublishPermissions has been called."); } if (validatePermissions(permissions, SessionAuthorizationType.READ, session)) { this.permissions = permissions; authorizationType = SessionAuthorizationType.READ; } }