79
79
import com.eucalyptus.bootstrap.Depends;
80
80
import com.eucalyptus.bootstrap.Provides;
81
81
import com.eucalyptus.bootstrap.Resource;
82
import com.eucalyptus.util.DatabaseUtil;
83
import com.eucalyptus.util.EntityWrapper;
82
import com.eucalyptus.entities.DatabaseUtil;
83
import com.eucalyptus.entities.EntityWrapper;
84
84
import com.eucalyptus.util.EucalyptusCloudException;
85
85
import com.google.common.collect.Lists;
287
public static List<User> getEnabledUsers( ) {
288
EntityWrapper<User> db = Credentials.getEntityWrapper( );
290
return db.query( new User( null, true ) );
287
296
public static List<User> getAllUsers( ) {
288
297
EntityWrapper<User> db = Credentials.getEntityWrapper( );
290
return db.query( new User( null, true ) );
299
return db.query( new User( null ) );
296
306
public static User addUser( String userName, Boolean isAdmin, String queryId, String secretKey ) throws UserExistsException {
297
User newUser = new User( userName, true );
307
return CredentialProvider.addUser( userName, isAdmin, queryId, secretKey, true );
309
public static User addUser( String userName, Boolean isAdmin, String queryId, String secretKey, Boolean isEnabled ) throws UserExistsException {
310
User newUser = new User( userName);
298
311
newUser.setQueryId( queryId );
299
312
newUser.setSecretKey( secretKey );
300
313
newUser.setIsAdministrator( isAdmin );
314
newUser.setIsEnabled( isEnabled );
301
315
EntityWrapper<User> db = Credentials.getEntityWrapper( );
303
317
db.add( newUser );
305
} catch ( Exception e ) {
319
} catch ( Throwable t ) {
307
throw new UserExistsException( e );
321
throw new UserExistsException( t );
326
public static User addDisabledUser( String userName, Boolean isAdmin ) throws UserExistsException {
327
String queryId = Hashes.getDigestBase64( userName, Hashes.Digest.SHA224, false ).replaceAll( "\\p{Punct}", "" );
328
String secretKey = Hashes.getDigestBase64( userName, Hashes.Digest.SHA224, true ).replaceAll( "\\p{Punct}", "" );
329
return CredentialProvider.addUser( userName, isAdmin, queryId, secretKey, false );
312
331
public static User addUser( String userName, Boolean isAdmin ) throws UserExistsException {
313
332
String queryId = Hashes.getDigestBase64( userName, Hashes.Digest.SHA224, false ).replaceAll( "\\p{Punct}", "" );
314
333
String secretKey = Hashes.getDigestBase64( userName, Hashes.Digest.SHA224, true ).replaceAll( "\\p{Punct}", "" );
344
363
throw new NoSuchUserException( e );
367
public static String generateConfirmationCode( String userName ) {
368
return Hashes.getDigestBase64( userName, Hashes.Digest.SHA512, true ).replaceAll("\\p{Punct}", "" );
371
public static String generateCertificateCode( String userName ) {
372
return Hashes.getDigestBase64( userName, Hashes.Digest.SHA512, true ).replaceAll("\\p{Punct}", "" );
375
public static String generateSecretKey( String userName ) {
376
return Hashes.getDigestBase64( userName, Hashes.Digest.SHA224, true ).replaceAll("\\p{Punct}", "" );
379
public static String generateQueryId( String userName ) {
380
return Hashes.getDigestBase64( userName, Hashes.Digest.MD5, false ).replaceAll("\\p{Punct}", "" );