All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.usergrid.management.ManagementService Maven / Gradle / Ivy

There is a newer version: 0.0.27.1
Show newest version
/*******************************************************************************
 * Copyright 2012 Apigee Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package org.usergrid.management;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.usergrid.persistence.CredentialsInfo;
import org.usergrid.persistence.Entity;
import org.usergrid.persistence.EntityRef;
import org.usergrid.persistence.Identifier;
import org.usergrid.persistence.entities.Application;
import org.usergrid.persistence.entities.Group;
import org.usergrid.persistence.entities.User;
import org.usergrid.security.oauth.AccessInfo;
import org.usergrid.security.shiro.PrincipalCredentialsToken;
import org.usergrid.services.ServiceResults;

import com.google.common.collect.BiMap;

public interface ManagementService {

	public void activateAdminUser(UUID userId) throws Exception;

	public void activateOrganization(OrganizationInfo organization)
			throws Exception;

	public void addAdminUserToOrganization(UserInfo user,
			OrganizationInfo organization, boolean email) throws Exception;

	public UUID addApplicationToOrganization(UUID organizationId,
			UUID applicationId) throws Exception;

	public AccessInfo authorizeClient(String clientId, String clientSecret, long ttl)
			throws Exception;

	public ActivationState handleConfirmationTokenForAdminUser(UUID userId,
			String token) throws Exception;

	public ActivationState handleActivationTokenForAdminUser(UUID userId,
			String token) throws Exception;

	public ActivationState handleActivationTokenForOrganization(
			UUID organizationId, String token) throws Exception;

	public boolean checkPasswordResetTokenForAdminUser(UUID userId, String token)
			throws Exception;

	public UserInfo createAdminUser(String username, String name, String email,
			String password, boolean activated, boolean disabled) throws Exception;

    public UserInfo createAdminUser(String username, String name, String email,
   			String password, boolean activated, boolean disabled,
            Map userProperties) throws Exception;

	public UserInfo createAdminFrom(User user, String password) throws Exception;

	public UserInfo createAdminFromPrexistingPassword(User user, CredentialsInfo ci) throws Exception;

	public ApplicationInfo createApplication(UUID organizationId, String applicationName)
			throws Exception;

	public ApplicationInfo createApplication(UUID organizationId, String applicationName,
			Map properties) throws Exception;

	public OrganizationInfo createOrganization(String organizationName,
			UserInfo user, boolean activated) throws Exception;

  public OrganizationOwnerInfo createOwnerAndOrganization(
 			String organizationName, String username, String name,
 			String email, String password) throws Exception;

	public OrganizationOwnerInfo createOwnerAndOrganization(
			String organizationName, String username, String name,
			String email, String password, boolean activated, boolean disabled) throws Exception;

    public OrganizationOwnerInfo createOwnerAndOrganization(
   			String organizationName, String username, String name,
   			String email, String password, boolean activated, boolean disabled,
        Map userProperties, Map properties) throws Exception;

  public void updateOrganization(OrganizationInfo organizationInfo) throws Exception;

    /**
     * Deactivate the user and return it's current state
     * @param applicationId
     * @param userId
     * @return
     * @throws Exception
     */
	public User deactivateUser(UUID applicationId, UUID userId) throws Exception;

	public void deactivateOrganization(UUID organizationId) throws Exception;

	public void deleteOrganizationApplication(UUID organizationId,
			UUID applicationId) throws Exception;

	public void disableAdminUser(UUID userId) throws Exception;

	public void disableOrganization(UUID organizationId) throws Exception;

	public void enableAdminUser(UUID userId) throws Exception;

	public void enableOrganization(UUID organizationId) throws Exception;

	public UserInfo findAdminUser(String identifier);

	public String getAccessTokenForAdminUser(UUID userId, long duration) throws Exception;

	/**
	 * Revoke all active access tokens for this admin user
	 * @param userId
	 * @throws Exception
	 */
	public void revokeAccessTokensForAdminUser(UUID userId) throws Exception;

	public void revokeAccessTokenForAdminUser(UUID userId, String token) throws Exception;

	public String getActivationTokenForAdminUser(UUID userId, long ttl) throws Exception;

	public String getConfirmationTokenForAdminUser(UUID userId, long ttl)
			throws Exception;

	public String getActivationTokenForOrganization(UUID organizationId, long ttl)
			throws Exception;

	public ServiceResults getAdminUserActivities(UserInfo user)
			throws Exception;

	public ServiceResults getAdminUserActivity(UserInfo user) throws Exception;

	public UserInfo getAdminUserByEmail(String email) throws Exception;

	public UserInfo getAdminUserByIdentifier(Identifier id) throws Exception;

	public UserInfo getAdminUserByUsername(String username) throws Exception;

	public Entity getAdminUserEntityByIdentifier(Identifier id)
			throws Exception;

	public Entity getAdminUserEntityByUuid(UUID id) throws Exception;

	public Entity getAdminUserEntityFromAccessToken(String token)
			throws Exception;

	public UserInfo getAdminUserInfoFromAccessToken(String token)
			throws Exception;

	public Map getAdminUserOrganizationData(UserInfo user)
			throws Exception;

	public Map getAdminUserOrganizationData(UUID userId)
			throws Exception;

	public List getAdminUsersForOrganization(UUID organizationId)
			throws Exception;

	public ApplicationInfo getApplicationInfo(String applicationName)
			throws Exception;

	public ApplicationInfo getApplicationInfo(UUID applicationId)
			throws Exception;

	public ApplicationInfo getApplicationInfo(Identifier id) throws Exception;

	public ApplicationInfo getApplicationInfoFromAccessToken(String token)
			throws Exception;

	public ServiceResults getApplicationMetadata(UUID applicationId)
			throws Exception;

	public BiMap getApplicationsForOrganization(
			UUID organizationId) throws Exception;

	public BiMap getApplicationsForOrganizations(
			Set organizationIds) throws Exception;

	public String getClientIdForApplication(UUID applicationId);

	public String getClientIdForOrganization(UUID organizationId);

	public String getClientSecretForApplication(UUID applicationId)
			throws Exception;

	public String getClientSecretForOrganization(UUID organizationId)
			throws Exception;

	public ServiceResults getOrganizationActivity(OrganizationInfo organization)
			throws Exception;

	public ServiceResults getOrganizationActivityForAdminUser(
			OrganizationInfo organization, UserInfo user) throws Exception;

	public OrganizationInfo getOrganizationByIdentifier(Identifier id)
			throws Exception;

	public OrganizationInfo getOrganizationByName(String organizationName)
			throws Exception;

	public OrganizationInfo getOrganizationByUuid(UUID id) throws Exception;

	public Map getOrganizationData(OrganizationInfo organization)
			throws Exception;

	public OrganizationInfo getOrganizationForApplication(UUID applicationId)
			throws Exception;

	public OrganizationInfo getOrganizationInfoFromAccessToken(String token)
			throws Exception;

	public BiMap getOrganizations() throws Exception;

	public BiMap getOrganizationsForAdminUser(UUID userId)
			throws Exception;

	public String getPasswordResetTokenForAdminUser(UUID userId, long ttl)
			throws Exception;

	public UserInfo getAdminUserByUuid(UUID id) throws Exception;

	public UUID importApplication(UUID organizationId, Application application)
			throws Exception;

	public OrganizationInfo importOrganization(UUID organizationId,
			OrganizationInfo organizationInfo, Map properties)
			throws Exception;

	public boolean isAdminUserActivated(UUID userId) throws Exception;

	public boolean isAdminUserEnabled(UUID userId) throws Exception;

	public boolean isOrganizationActivated(UUID organizationId)
			throws Exception;

	public boolean isOrganizationEnabled(UUID organizationId) throws Exception;

	public boolean newAdminUsersNeedSysAdminApproval();

	public boolean newAdminUsersRequireConfirmation();

	public String newClientSecretForApplication(UUID applicationId)
			throws Exception;

	public String newClientSecretForOrganization(UUID organizationId)
			throws Exception;

	public boolean newOrganizationsNeedSysAdminApproval();

	public void postOrganizationActivity(UUID organizationId, UserInfo user,
			String verb, EntityRef object, String objectType,
			String objectName, String title, String content) throws Exception;

	public void removeAdminUserFromOrganization(UUID userId, UUID organizationId)
			throws Exception;

	public void removeOrganizationApplication(UUID organizationId,
			UUID applicationId) throws Exception;

	public void startAdminUserActivationFlow(UserInfo user) throws Exception;

	public void sendAdminUserEmail(UserInfo user, String subject, String html)
			throws Exception;

	public void startAdminUserPasswordResetFlow(UserInfo user) throws Exception;

	public void startOrganizationActivationFlow(OrganizationInfo organization)
			throws Exception;

	public void sendOrganizationEmail(OrganizationInfo organization,
			String subject, String html) throws Exception;

	public void setAdminUserPassword(UUID userId, String newPassword)
			throws Exception;

	public void setAdminUserPassword(UUID userId, String oldPassword,
			String newPassword) throws Exception;

	public void setup() throws Exception;

	public UserInfo updateAdminUser(UserInfo user, String username,
                                    String name, String email, Map json) throws Exception;

	public boolean verifyAdminUserPassword(UUID userId, String password)
			throws Exception;

	public UserInfo verifyAdminUserPasswordCredentials(String name,
			String password) throws Exception;

	public UserInfo verifyMongoCredentials(String name, String nonce, String key)
			throws Exception;

	public void activateAppUser(UUID applicationId, UUID userId)
			throws Exception;

	public ActivationState handleActivationTokenForAppUser(UUID applicationId,
			UUID userId, String token) throws Exception;

	public ActivationState handleConfirmationTokenForAppUser(
			UUID applicationId, UUID userId, String token) throws Exception;

	public boolean checkPasswordResetTokenForAppUser(UUID applicationId,
			UUID userId, String token) throws Exception;

	public String getAccessTokenForAppUser(UUID applicationId, UUID userId, long duration)
			throws Exception;

  public Long getLastAdminPasswordChange(UUID userId) throws Exception;

	/**
     * Revoke all active access tokens for this admin user
     * @param userId
	 * @throws Exception
     */
    public void revokeAccessTokensForAppUser(UUID applicationId, UUID userId) throws Exception;

    public void revokeAccessTokenForAppUser(String token) throws Exception;

	public User getAppUserByIdentifier(UUID applicationId, Identifier identifier)
			throws Exception;

	public void startAppUserPasswordResetFlow(UUID applicationId, User user)
			throws Exception;

	public void startAppUserActivationFlow(UUID applicationId, User user)
			throws Exception;

	public void setAppUserPassword(UUID applicationId, UUID userId,
			String newPassword) throws Exception;

	public void setAppUserPassword(UUID applicationId, UUID userId,
			String oldPassword, String newPassword) throws Exception;

	public User verifyAppUserPasswordCredentials(UUID applicationId,
			String name, String password) throws Exception;

	public UserInfo getAppUserFromAccessToken(String token) throws Exception;

	public void setAppUserPin(UUID applicationId, UUID userId, String newPin)
			throws Exception;

	public void sendAppUserPin(UUID applicationId, UUID userId)
			throws Exception;

	public User verifyAppUserPinCredentials(UUID applicationId, String name,
			String pin) throws Exception;

	public PrincipalCredentialsToken getPrincipalCredentialsTokenForClientCredentials(
			String clientId, String clientSecret) throws Exception;

	public void confirmAdminUser(UUID userId) throws Exception;

	public void unconfirmAdminUser(UUID userId) throws Exception;

	public boolean isAdminUserConfirmed(UUID userId) throws Exception;

	public void countAdminUserAction(UserInfo user, String action)
			throws Exception;

	public boolean newAppUsersNeedAdminApproval(UUID applicationId)
			throws Exception;

	public boolean newAppUsersRequireConfirmation(UUID applicationId)
			throws Exception;

  public abstract void provisionSuperuser() throws Exception;

  public List getOrganizations(UUID startResult, int count) throws Exception;
  
  /**
   * Add the properties to the organization
   * @param orgId
   * @param props
   * @throws Exception 
   */
  public void setOrganizationProps(UUID orgId, Map props) throws Exception;
  
  /**
   * Get the organization properties, returns them in the group object
   * @param orgId
   * @return
   * @throws Exception 
   */
  public Group getOrganizationProps(UUID orgId) throws Exception;
  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy