public ApiKey createApiKey ( final Team team ) { final List < Team > teams = new ArrayList <> ( ) ; teams . add ( team ) ; pm . currentTransaction ( ) . begin ( ) ; final ApiKey apiKey = new ApiKey ( ) ; apiKey . setKey ( ApiKeyGenerator . generate ( ) ) ; apiKey . setTeams ( teams ) ; pm . makePersistent ( apiKey ) ; pm . currentTransaction ( ) . commit ( ) ; return pm . getObjectById ( ApiKey . class , apiKey . getId ( ) ) ; }
Creates a new ApiKey object including a cryptographically secure API key string .