agave-systems/systems-core/src/main/java/org/iplantc/service/systems/manager/SystemManager.java
/**
	 * Deletes an AuthConfig for the given internal user.
	 *  
	 * @param system
	 * @param remoteConfigType
	 * @param apiUsername
	 * @param internalUsername
	 * @throws SystemArgumentException
	 * @throws PermissionException 
	 */
Deletes an AuthConfig for the given internal user.


Deletes an AuthConfig for the given internal user .
public void removeInternalUserAuthConfigOnSystemOfType(RemoteSystem system, 
			String remoteConfigType, String apiUsername, String internalUsername) 
	throws SystemArgumentException, PermissionException 
	{
		if (system == null) {
			throw new SystemArgumentException("No system provided.");
		} else if (system.isPubliclyAvailable()) {
			throw new SystemArgumentException("Internal users are not supported on public systems.");
		} else if (!system.getUserRole(apiUsername).getRole().canAdmin()) {
			throw new PermissionException("User does not have permission to manage internal user credentials on this system.");
		}
		if (StringUtils.isEmpty(apiUsername)) {
			throw new SystemArgumentException("No username provided.");
		}
		if (StringUtils.isEmpty(internalUsername)) {
			throw new SystemArgumentException("No internal username provided.");
		}
		if (remoteConfigType == null) {
			throw new SystemArgumentException("No credential type provided. " +
					"Please specify either 'lobin' or 'storage'");
		} else if (!remoteConfigType.equalsIgnoreCase("storage") && 
				!remoteConfigType.equalsIgnoreCase("login")) {
			throw new SystemArgumentException("Invalid credential type '" + 
				remoteConfigType + "'. Please specify either 'login' or 'storage'");
		} else if (remoteConfigType.equalsIgnoreCase("login")) {
			if (!(system instanceof ExecutionSystem)) {
				throw new SystemArgumentException("Invalid credential type. " + 
						 "Only execution systems can have login credentials.");
			}
		}
		if (remoteConfigType.equalsIgnoreCase("storage")) 
		{
			AuthConfig userAuthConfig = system.getStorageConfig().getAuthConfigForInternalUsername(internalUsername);
			if (!userAuthConfig.isSystemDefault()) {
				for (AuthConfig config: system.getStorageConfig().getAuthConfigs()) {
					if (StringUtils.equals(internalUsername, config.getInternalUsername())) {
						system.getStorageConfig().getAuthConfigs().remove(config);
						getDao().persist(system);
						getEventProcessor().processSystemUpdateEvent(system, SystemEventType.REMOVE_CREDENTIAL, internalUsername);
						break;
					}
				}
			}
		} 
		else 
		{
			AuthConfig userAuthConfig = ((ExecutionSystem)system).getLoginConfig().getAuthConfigForInternalUsername(internalUsername);
			if (!userAuthConfig.isSystemDefault()) {
				for (AuthConfig config: ((ExecutionSystem)system).getLoginConfig().getAuthConfigs()) {
					if (config.getInternalUsername() != null && internalUsername.equals(config.getInternalUsername())) {
						((ExecutionSystem)system).getLoginConfig().getAuthConfigs().remove(config);
						getDao().persist(system);
						getEventProcessor().processSystemUpdateEvent(system, SystemEventType.REMOVE_CREDENTIAL, internalUsername);
						break;
					}
				}
			}
		}
	}
public void removeInternalUserAuthConfigOnSystemOfType ( RemoteSystem system , String remoteConfigType , String apiUsername , String internalUsername ) throws SystemArgumentException , PermissionException { if ( system == null ) { throw new SystemArgumentException ( "No system provided." ) ; } else if ( system . isPubliclyAvailable ( ) ) { throw new SystemArgumentException ( "Internal users are not supported on public systems." ) ; } else if ( ! system . getUserRole ( apiUsername ) . getRole ( ) . canAdmin ( ) ) { throw new PermissionException ( "User does not have permission to manage internal user credentials on this system." ) ; } if ( StringUtils . isEmpty ( apiUsername ) ) { throw new SystemArgumentException ( "No username provided." ) ; } if ( StringUtils . isEmpty ( internalUsername ) ) { throw new SystemArgumentException ( "No internal username provided." ) ; } if ( remoteConfigType == null ) { throw new SystemArgumentException ( "No credential type provided. " + "Please specify either 'lobin' or 'storage'" ) ; } else if ( ! remoteConfigType . equalsIgnoreCase ( "storage" ) && ! remoteConfigType . equalsIgnoreCase ( "login" ) ) { throw new SystemArgumentException ( "Invalid credential type '" + remoteConfigType + "'. Please specify either 'login' or 'storage'" ) ; } else if ( remoteConfigType . equalsIgnoreCase ( "login" ) ) { if ( ! ( system instanceof ExecutionSystem ) ) { throw new SystemArgumentException ( "Invalid credential type. " + "Only execution systems can have login credentials." ) ; } } if ( remoteConfigType . equalsIgnoreCase ( "storage" ) ) { AuthConfig userAuthConfig = system . getStorageConfig ( ) . getAuthConfigForInternalUsername ( internalUsername ) ; if ( ! userAuthConfig . isSystemDefault ( ) ) { for ( AuthConfig config : system . getStorageConfig ( ) . getAuthConfigs ( ) ) { if ( StringUtils . equals ( internalUsername , config . getInternalUsername ( ) ) ) { system . getStorageConfig ( ) . getAuthConfigs ( ) . remove ( config ) ; getDao ( ) . persist ( system ) ; getEventProcessor ( ) . processSystemUpdateEvent ( system , SystemEventType . REMOVE_CREDENTIAL , internalUsername ) ; break ; } } } } else { AuthConfig userAuthConfig = ( ( ExecutionSystem ) system ) . getLoginConfig ( ) . getAuthConfigForInternalUsername ( internalUsername ) ; if ( ! userAuthConfig . isSystemDefault ( ) ) { for ( AuthConfig config : ( ( ExecutionSystem ) system ) . getLoginConfig ( ) . getAuthConfigs ( ) ) { if ( config . getInternalUsername ( ) != null && internalUsername . equals ( config . getInternalUsername ( ) ) ) { ( ( ExecutionSystem ) system ) . getLoginConfig ( ) . getAuthConfigs ( ) . remove ( config ) ; getDao ( ) . persist ( system ) ; getEventProcessor ( ) . processSystemUpdateEvent ( system , SystemEventType . REMOVE_CREDENTIAL , internalUsername ) ; break ; } } } } }
Deletes an AuthConfig for the given internal user.
Deletes an AuthConfig for the given internal user .
// make sure they're requesting a valid config type for this auth config // delete the current auth config for the given internal user. //						NotificationManager.process(system.getUuid(), "REMOVE_CREDENTIAL", internalUsername); //						NotificationManager.process(system.getUuid(), "REMOVE_CREDENTIAL", internalUsername);